我正在使用基于云的 Azure SQL Server 和 SQL 資料庫。為了對資料庫中的表進行分組,我“成功地”創建了一個新模式。但是,所有使用架構的嘗試都會導致關于沒有權限的錯誤,我找不到添加權限的方法(見下文)。麻煩不值得進行故障排除,所以我放棄了這個想法并回到我現有的單一模式名稱。
從那以后,我無法再在名為 qbo 的原始模式上創建表:
CREATE TABLE qbo.NewTable (
pkey int PRIMARY KEY,
);
Started executing query at Line 1
Msg 2760, Level 16, State 1, Line 1
The specified schema name "qbo" either does not exist or you do not have permission to use it.
Total execution time: 00:00:00.034
我可以創建一個完全沒有指定架構的表(我假設它是 dbo),或者指定了 dbo,但是我無法查詢所述表,因為 SELECT 權限被拒絕。
CREATE TABLE [dbo].[NewTable] (
pkey int PRIMARY KEY,
);
Started executing query at Line 1
Commands completed successfully.
Total execution time: 00:00:00.194
SELECT * FROM [dbo].[NewTable]
Started executing query at Line 1
Msg 229, Level 14, State 5, Line 1
The SELECT permission was denied on the object 'NewTable', database 'master', schema 'dbo'.
Total execution time: 00:00:00.036
當我嘗試授予權限時:
GRANT CONTROL ON SCHEMA :: dbo TO <myUserName>
Started executing query at Line 1
Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.
Total execution time: 00:00:00.035
我是唯一的 db 用戶,也是擁有 Owner 角色的服務器管理員。我還沒有找到通過門戶更改任何內容的方法,并且 Azure Data Studio 中的任何 T-SQL 陳述句嘗試更正所有內容都會導致上述相同型別的錯誤。我假設在創建另一個模式時改變了一些后端設定。但據我所知,自從創建資料庫以來,我并沒有特別撤銷我開始使用的任何權限,該資料庫已經通過 CREATE、UPDATE、DROP 等順利運行了大約 3 個月。
至少,我需要回到完全操作我自己的 db 和 qbo 模式,但額外的功勞幫助我了解我搞砸了什么以及我是否可以實際使用多個模式。謝謝!
UPDATE: Based on your helpful comments and re-reading my own error messages, it finally clicked that I'm connected to different databases. I assumed at first that the db I created was the master db, so the comment didn't make sense. I don't know what the "master" db is yet (default?), but changing the Change Connection drop-down to my main db has cleared up most everything. Not sure how I changed it in the first place, but now I know to look there.
I'm still working on understanding the schemas, but at least I can get work done again.
uj5u.com熱心網友回復:
根據您的有用評論并重新閱讀我自己的錯誤訊息,它終于點擊了我連接到不同的資料庫。我一開始以為我創建的資料庫是主資料庫,所以評論沒有意義。
到目前為止,我一直在我專門創建的資料庫中作業,而沒有意識到有一個主資料庫,并且不知何故在 Azure Data Studio 中,我現在正在連接到主資料庫。這可能與我對模式創建的理解無關;我只是假設它們是相關的問題,因為它們同時發生。
為了解決這個問題,我將更改連接下拉選單更改為我的主資料庫。之后,我可以再次創建、更新、洗掉等。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/343720.html
標籤:sql-server azure tsql
上一篇:計算兩個日期之間的天數
下一篇:如果前面沒有相同字符,則替換字符
