{"id":1762,"date":"2025-10-01T14:26:19","date_gmt":"2025-10-01T14:26:19","guid":{"rendered":"https:\/\/www.versionsql.com\/help\/?post_type=docs&#038;p=1762"},"modified":"2025-10-01T14:26:19","modified_gmt":"2025-10-01T14:26:19","slug":"static-data-scripting","status":"publish","type":"docs","link":"https:\/\/www.versionsql.com\/help\/documentation\/features\/static-data-scripting\/","title":{"rendered":"Static Data Scripting"},"content":{"rendered":"<p data-start=\"102\" data-end=\"264\">Version control table rows as part of your repository. Use it for small, static or semi-static reference tables and enumerations that must deploy alongside schema.<\/p>\n<h2 data-start=\"266\" data-end=\"280\">When to Use<\/h2>\n<ul data-start=\"281\" data-end=\"435\">\n<li data-start=\"281\" data-end=\"344\">\n<p data-start=\"283\" data-end=\"344\">Lookup tables (aka static tables, aka reference tables): statuses, countries, tax rates, feature flags.<\/p>\n<\/li>\n<li data-start=\"345\" data-end=\"382\">\n<p data-start=\"347\" data-end=\"382\">Seed or configuration data required for app startup.<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"437\" data-end=\"488\">Avoid for high-churn or large transactional tables. A warning appears above 1,000 rows.<\/p>\n<h2 data-start=\"490\" data-end=\"505\">How It Works<\/h2>\n<p data-start=\"506\" data-end=\"690\">You \u201clink\u201d a table&#8217;s data to source control. VersionSQL scripts those rows to a file in your repo. You can see data changes during a commit by examining file diffs. Deployments read the files and apply changes to the target database.<\/p>\n<h2 data-start=\"1617\" data-end=\"1632\">Requirements<\/h2>\n<ul data-start=\"1633\" data-end=\"1741\">\n<li data-start=\"1633\" data-end=\"1669\">\n<p data-start=\"1635\" data-end=\"1669\">Table must have a <strong data-start=\"1653\" data-end=\"1668\">primary key<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"1743\" data-end=\"1768\">Link or Unlink a Table<\/h2>\n<ol data-start=\"1769\" data-end=\"1942\">\n<li data-start=\"1769\" data-end=\"1830\">\n<p data-start=\"1772\" data-end=\"1830\">Right-click a table \u2192 <strong data-start=\"1794\" data-end=\"1827\">VersionSQL \u2192 Link Static Data<\/strong>.<\/p>\n<\/li>\n<li data-start=\"1831\" data-end=\"1892\">\n<p data-start=\"1834\" data-end=\"1892\">The menu shows a <strong data-start=\"1851\" data-end=\"1864\">checkmark<\/strong> when the table is linked.<\/p>\n<\/li>\n<li data-start=\"1893\" data-end=\"1942\">\n<p data-start=\"1896\" data-end=\"1942\">To stop scripting this table&#8217;s data, use <strong data-start=\"1919\" data-end=\"1941\">Unlink Static Data<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<h2 data-start=\"2018\" data-end=\"2035\">Script Formats<\/h2>\n<ul data-start=\"2036\" data-end=\"2191\">\n<li data-start=\"2036\" data-end=\"2118\">\n<p data-start=\"2038\" data-end=\"2118\"><strong data-start=\"2038\" data-end=\"2072\">Upsert (insert\/update\/delete):<\/strong> Default. Generates a script that fills a temp table with rows and runs separate insert, update, and delete statements to keep data in sync.<\/p>\n<\/li>\n<li data-start=\"2119\" data-end=\"2191\">\n<p data-start=\"2121\" data-end=\"2191\"><strong data-start=\"2121\" data-end=\"2138\">Inserts only:<\/strong> Generates a long list of insert statements, with a truncate statement at the top (disabled by default). Less flexible, but similar to the output of other tooling. Useful if your deployment pipeline or auditors require a flat file of inserts.<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"2193\" data-end=\"2238\">Choose the format per connection in settings.<\/p>\n<h2 data-start=\"2240\" data-end=\"2259\">Folder and Files<\/h2>\n<ul data-start=\"2260\" data-end=\"2428\">\n<li data-start=\"2260\" data-end=\"2332\">\n<p data-start=\"2262\" data-end=\"2332\">Files are saved under a data folder in your repo. Default: <strong data-start=\"2321\" data-end=\"2331\"><code data-start=\"2323\" data-end=\"2329\">Data<\/code><\/strong>.<\/p>\n<\/li>\n<li data-start=\"2333\" data-end=\"2428\">\n<p data-start=\"2335\" data-end=\"2428\">Folder name is configurable (choose from presets or type your own).<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"2430\" data-end=\"2442\">Configure<\/h2>\n<p data-start=\"2443\" data-end=\"2480\"><strong data-start=\"2443\" data-end=\"2480\">Connection Settings \u2192 Advanced \u2192 Static Data<\/strong><\/p>\n<ul data-start=\"2481\" data-end=\"2635\">\n<li data-start=\"2481\" data-end=\"2523\">\n<p data-start=\"2483\" data-end=\"2523\">Add or remove linked tables.<\/p>\n<\/li>\n<li data-start=\"2524\" data-end=\"2571\">\n<p data-start=\"2526\" data-end=\"2571\">Choose <strong data-start=\"2533\" data-end=\"2550\">Script format<\/strong> and <strong data-start=\"2555\" data-end=\"2570\">Data folder<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"2637\" data-end=\"2659\">Commits and History<\/h2>\n<ul data-start=\"2660\" data-end=\"2805\">\n<li data-start=\"2660\" data-end=\"2714\">\n<p data-start=\"2662\" data-end=\"2714\">Linked tables generate file diffs when data changes.<\/p>\n<\/li>\n<li data-start=\"2715\" data-end=\"2805\">\n<p data-start=\"2717\" data-end=\"2805\">The <strong data-start=\"2721\" data-end=\"2732\">History<\/strong> view for a linked table shows <strong data-start=\"2763\" data-end=\"2787\">both schema and data<\/strong> changes together.<\/p>\n<\/li>\n<\/ul>\n<h2 data-start=\"2807\" data-end=\"2821\">Deployments<\/h2>\n<ul data-start=\"2822\" data-end=\"2970\">\n<li data-start=\"2822\" data-end=\"2918\">\n<p data-start=\"2824\" data-end=\"2918\">Static data files are applied during deployment.<\/p>\n<\/li>\n<li data-start=\"2919\" data-end=\"2970\">\n<p data-start=\"2921\" data-end=\"2970\">Deletions are disabled by default and can be enabled by changing the <strong data-start=\"2321\" data-end=\"2331\"><code data-start=\"2323\" data-end=\"2329\">StaticDataEnableDeletes<\/code> <\/strong>SQLCMD variable at the top of the deployment script.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"parent":98,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"doc_tag":[],"class_list":["post-1762","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/1762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/comments?post=1762"}],"version-history":[{"count":4,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/1762\/revisions"}],"predecessor-version":[{"id":1766,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/1762\/revisions\/1766"}],"up":[{"embeddable":true,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/98"}],"next":[{"title":"Scan for Uncommitted Changes","link":"https:\/\/www.versionsql.com\/help\/documentation\/features\/scan-for-uncommitted-changes\/","href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/1772"}],"prev":[{"title":"View Changes","link":"https:\/\/www.versionsql.com\/help\/documentation\/features\/view-changes\/","href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/docs\/99"}],"wp:attachment":[{"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/media?parent=1762"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.versionsql.com\/help\/wp-json\/wp\/v2\/doc_tag?post=1762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}