如何在SQL中更改已创建的表的模式? [英] How to alter a schema of already created table in SQL?
本文介绍了如何在SQL中更改已创建的表的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
如何更改SQL中已创建的表的架构?
我尝试过以下方法:
改变架构dbo TRANSFER [xxx]。[MytableName]并得到以下错误消息。
消息15151,Level 16,State 1,Line 3
找不到对象'LANGUAGE_TYPE',因为它不存在或您没有权限。
有没有办法做到这一点?请帮助
问候
DhivyaJ
Hi
How to alter a schema of already created table in SQL?
I tried the below:
alter schema dbo TRANSFER [xxx].[MytableName] and got the below error msg.
Msg 15151, Level 16, State 1, Line 3
Cannot find the object 'LANGUAGE_TYPE', because it does not exist or you do not have permission.
Is there any othe way to do this? Pls help
Regards
DhivyaJ
推荐答案
根据你的评论你尝试将MyTableName
表从dbo
移至xxx
.. 。
你命令尝试做相反的事情。
ALTER SCHEMA的格式是这样的
According to your comment you try to moveMyTableName
table fromdbo
toxxx
...
You command try to do just the opposite.
The format of ALTER SCHEMA goes like this
ALTER SCHEMA {target-schema-name} TRANSFER {original-schema-name}.{table-name}
在你的情况下
In you case
ALTER SCHEMA xxx TRANSFER dbo.MyTableName
例如,参见这个Stack Overflow问题 [ ^ ]。
在你的sql server中是否有任何名为xxx的模式,如果没有,那么创建一个
is there any schema named xxx in your sql server if not then create one
CREATE SCHEMA xxx
然后尝试改变你的表格
then try alter Your Table Like
ALTER SCHEMA NewSchema TRANSFER OldSchema.YourTable
GO
了解更多细节请参阅 ALTER SCHEMA(Transact-SQL)
这篇关于如何在SQL中更改已创建的表的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文