{"id":191,"date":"2025-02-24T12:51:26","date_gmt":"2025-02-24T11:51:26","guid":{"rendered":"https:\/\/blog.ctr24.co.pl\/?p=191"},"modified":"2025-02-24T12:51:26","modified_gmt":"2025-02-24T11:51:26","slug":"kopiowanie-tabel-sql","status":"publish","type":"post","link":"https:\/\/blog.ctr24.co.pl\/?p=191","title":{"rendered":"Kopiowanie tabel SQL"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1. <strong>Utworzenie tabeli docelowej na podstawie struktury tabeli \u017ar\u00f3d\u0142owej<\/strong><\/h3>\n\n\n\n<p>Je\u015bli chcesz skopiowa\u0107 <strong>tylko struktur\u0119<\/strong> tabeli (bez danych), u\u017cyj <code>CREATE TABLE ... LIKE<\/code>:<\/p>\n\n\n<div style=\"margin-bottom:50px\" class=\"wp-block-cblocks-coder-block\"><pre class=\"im-coder-block\" data-mode=\"mysql\" data-theme=\"twilight\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\">CREATE TABLE target_database.target_table LIKE source_database.source_table;<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Utworzenie tabeli docelowej i skopiowanie danych<\/strong><\/h3>\n\n\n\n<p>Je\u015bli chcesz utworzy\u0107 tabel\u0119 i od razu skopiowa\u0107 do niej dane, u\u017cyj <code>CREATE TABLE ... AS<\/code>:<\/p>\n\n\n<div style=\"margin-bottom:50px\" class=\"wp-block-cblocks-coder-block\"><pre class=\"im-coder-block\" data-mode=\"mysql\" data-theme=\"twilight\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\">CREATE TABLE target_database.target_table AS\nSELECT * FROM source_database.source_table;<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Utworzenie tabeli z wybranymi kolumnami<\/strong><\/h3>\n\n\n\n<p>Je\u015bli nie potrzebujesz wszystkich kolumn z tabeli \u017ar\u00f3d\u0142owej, mo\u017cesz wybra\u0107 konkretne kolumny:<\/p>\n\n\n<div style=\"margin-bottom:50px\" class=\"wp-block-cblocks-coder-block\"><pre class=\"im-coder-block\" data-mode=\"mysql\" data-theme=\"twilight\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\">CREATE TABLE target_database.target_table AS\nSELECT col1, col2, col3 FROM source_database.source_table;<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Utworzenie tabeli docelowej na podstawie struktury tabeli \u017ar\u00f3d\u0142owej Je\u015bli chcesz skopiowa\u0107 tylko struktur\u0119 tabeli (bez danych), u\u017cyj CREATE TABLE<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-tips"],"_links":{"self":[{"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":1,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ctr24.co.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}