
create table test(username varchar(10), userinfo varchar(200), primary key (username) )
go
--修改字段名
exec sp_rename 'test.userinfo', 'userdesc', 'column';
go
sp_help test
go
--修改表名
exec sp_rename 'test', 'test1', 'object';
go
sp_help test1
go
--sp_rename
/* DOCUMENTATION:
[1] To rename a table, the @objname (meaning OldName) parm can be
passed in totally unqualified or fully qualified.
[2] The SA or DBO can rename objects owned by lesser users,
without the need for SetUser.
[3] The Owner portion of a qualified name can usually be
passed in in the omitted form (as in MyDb..MyTab or MyTab). The
typical exception is when the SA/DBO is trying to rename a table
where the @objname is present twice in sysobjects as a table
owned only by two different lesser users; requiring an explicit
owner qualifier in @objname.
[4] An unspecified Owner qualifier will default to the
current user if doing so will either resolve what would
otherwise be an ambiguity within @objtype, or will result
in exactly one match.
[5] If Database is part of the qualified @objname,
then it must match the current database. The @newname parm can
never be qualified.
[6] Here are the valid @objtype values. They correspond to
system tables which track each type:
'column' 'database' 'index' 'object' 'userdatatype'
The @objtype parm is sometimes required. It is always required
for databases. It is required whenever ambiguities would
otherwise exist. Explicit use of @objtype is always encouraged.
[7] Parms can use quoted_identifiers. For example:
Execute sp_rename 'amy."his table"','"her table"','object'
*/

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现