SQL ServerSQL server

sql server rename

2019-03-13  本文已影响2人  天天向上卡索

sql server rename

Intro

有时候我们可能会需要重命名表名称或列名称,这里就是解决方案

sometimes we may wanna rename the table name or the column name, here's the solution.

Caution

Changing any part of an object name can break scripts and stored procedures. We recommend you do not use this statement > to rename stored procedures, triggers, user-defined functions, or views; instead, drop the object and re-create it with the new > name.

execute sql

rename a table name:

重命名表名

exec sp_rename 'schema.old_table_name', 'new_table_name'
-- To rename a column:
sp_rename 'table_name.old_column_name', 'new_column_name' , 'COLUMN';

-- To rename a table:
sp_rename 'old_table_name','new_table_name';

Reference

上一篇 下一篇

猜你喜欢

热点阅读