{"id":132,"date":"2018-12-06T08:54:02","date_gmt":"2018-12-06T08:54:02","guid":{"rendered":"https:\/\/barkhane.com\/sql\/2018\/12\/06\/sql-rename-table\/"},"modified":"2024-03-03T18:02:03","modified_gmt":"2024-03-03T18:02:03","slug":"sql-rename-table","status":"publish","type":"post","link":"https:\/\/barkhane.com\/sql\/sql-rename-table\/","title":{"rendered":"SQL RENAME TABLE"},"content":{"rendered":"<p>SQL RENAME TABLE\u00a0syntax is used to change the name of a table. Sometimes, we choose non-meaningful name for the table. So it is required to be changed.<\/p>\n<p>Let\\&#8217;s see the syntax to rename a table from the database.<br \/>\n<code><\/code><\/p>\n<pre>ALTER \u00a0 TABLE  table_name\u00a0 \u00a0RENAME\u00a0 TO \u00a0new_table_name;<\/pre>\n<p>&nbsp;<\/p>\n<p>Optionally, you can write following command to rename the table.<br \/>\n<code><\/code><\/p>\n<pre>RENAME\u00a0old_table\u00a0_name\u00a0 To \u00a0new_table_name;<\/pre>\n<p>&nbsp;<\/p>\n<p>Let us take an example of a table named \\&#8221;STUDENTS\\&#8221;, now due to some reason we want to change it into table name \\&#8221;ARTISTS\\&#8221;.<\/p>\n<p>You should use any one of the following syntax to RENAME the table name:<\/p>\n<p><code><\/code><\/p>\n<pre><span class=\"keyword\">ALTER<\/span>\u00a0<span class=\"keyword\">TABLE<\/span>\u00a0STUDENTS\u00a0\u00a0RENAME\u00a0<span class=\"keyword\">TO<\/span>\u00a0ARTISTS;<\/pre>\n<p>or<br \/>\n<code><\/code><\/p>\n<pre>RENAME\u00a0STUDENTS\u00a0<span class=\"keyword\">TO<\/span>\u00a0ARTISTS;<\/pre>\n<p>After that\u00a0the\u00a0 table \u00a0 \\&#8221;students\\&#8221; \u00a0will\u00a0be\u00a0changed into table name \\&#8221;artists\\&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL RENAME TABLE\u00a0syntax is used to change the name of a table. Sometimes, we choose non-meaningful name for the table. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-sql"],"_links":{"self":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":0,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"wp:attachment":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}