Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Rename Table in SQL

Rename Table in SQL

? RENAME TABLE in SQL

The RENAME TABLE statement is used to rename an existing table to a new name.


? Syntax (MySQL, PostgreSQL, SQL Server, etc.)

? MySQL:

RENAME TABLE old_table_name TO new_table_name;

Example:

RENAME TABLE employees TO staff;

? PostgreSQL:

ALTER TABLE old_table_name RENAME TO new_table_name;

Example:

ALTER TABLE employees RENAME TO staff;

? SQL Server (T-SQL):

EXEC sp_rename 'old_table_name', 'new_table_name';

Example:

EXEC sp_rename 'employees', 'staff';

?? Notes:

  • Table structure and data remain unchanged.

  • You must have ALTER permission on the table.

  • If the table is referenced by foreign keys or views, update them accordingly.


Would you like a full example from table creation to renaming across databases?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql