在数据库 java NetBeans 中创建表权限被拒绝

时间:2021-05-28 19:32:47

标签: java sql-server netbeans mssql-jdbc

not able to create table in netbeans java connected to MS SQL server

错误-在数据库中创建表权限被拒绝

我如何获得权限。请提出一些解决方案。

2 个答案:

答案 0 :(得分:0)

要创建表,您的用户必须具有目标架构的 ALTER 权限和数据库的 CREATE TABLE 权限。这些权限可以由数据库所有者授予。

如果此 SQL Server 实例在您的 PC 上运行,请使用 SSMS 与 Windows 集成身份验证从提升的会话或使用 SA 帐户进行连接,并授予目标用户创建表的权限。连接到目标数据库运行

GRANT ALTER ON SCHEMA::DBO TO SomeUser
GRANT CREATE TABLE TO SomeUser

或者使该用户成为数据库级管理员

GRANT CONTROL TO SomeUser

答案 1 :(得分:0)

要创建表,您的登录名必须具有 db_owner 权限。这些权限可以由数据库所有者授予。

1. Launch "SQL Server Management Studio"
2. Expand <servername> - 'Security' - 'Logins'
3. Double-click on SQL login 'fastnet' // u have to open your created login
4. Inside the section 'Server Roles' ensure that the ONLY options ticked are 'bulkadmin' and 'public'. Do NOT tick any other options.
5. Inside the section 'User Mapping' highlight the your database
6. Ensure that the option 'Map' is ticked
7. Inside the window 'Database role membership for <databasename>' ensure that 'db_owner' and 'public' are ticked. Do NOT tick any other options.
8. Save changes and exit, login again with your login then test.