创建表权限 [英] Create table permission

查看:74
本文介绍了创建表权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在通过VB.NET代码从数据库级别的用户创建数据库,并且我想为其创建表...我在
中遇到了异常

Hi,

I am creating a database through VB.NET code from a database level user and i want to create a table to it...I am getting exception as

 " There is already an object named ''xHawk'' in the database.<br />
Cannot find the user ''test'', because it does not exist or you do not have permission."



xHawk是我创建的数据库..提前谢谢....请帮帮我...

这是我写的查询...



xHawk is the database i created..thanks in advance....please help me out...

Here is the query i wrote...

Dim strTable As String = "GRANT CREATE TABLE TO test  CREATE TABLE xHawk(StudentId INTEGER CONSTRAINT PkeyMyId PRIMARY KEY," + "Name CHAR(50)," + "Address CHAR(255)," + "Contact INTEGER);"

推荐答案



似乎您正在尝试创建一个已经存在的表,因此数据库中已经存在一个名为xHawk的对象".

尝试使用类似这样的方法,请注意,它将在再次创建表之前删除您的表:

Hi,

It seems you are trying to create an already existing table, hence the "There is already an object named xHawk in the database".

Try using something like this, beware it will delete you table before creating it again:

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[xHawk]') AND type = N'U')
DROP TABLE [dbo].[xHawk]



请注意[dbo],建议使用架构,但如果不这样做,则只需删除"[dbo]"即可.

希望对您有所帮助.



Notice the [dbo], it is recommended to use schemas but if you don''t, just remove "[dbo]".

Hope it helps.


_Zorro_所说的正确
您将不得不使用此
what _Zorro_ says is right
you will have to use this
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[xHawk]') AND type = N'U')
DROP TABLE [dbo].[xHawk]
go

GRANT CREATE TABLE TO test  CREATE TABLE xHawk(StudentId INTEGER CONSTRAINT PkeyMyId PRIMARY KEY,Name CHAR(50),Address CHAR(255),Contact INTEGER)


如果执行是相关的权限,则会出现以下错误.


If the execption is related permission it gives the following error.

Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.
The specified schema name "dbo" either does not exist or you do not have permission to use it.


这篇关于创建表权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆