是否可以創建一個數據庫,只需給它一個沒有文件名的邏輯名 - >這應該導致在數據庫名爲.mdf的默認路徑中創建數據庫?創建沒有文件名的數據庫?
CREATE DATABASE A
ON PRIMARY (
name = Z)
我發現這個來自微軟的文檔:
If data file name is not specified, SQL Server uses database_name as both the logical_file_name and as the os_file_name. The default path is obtained from the registry. The default path can be changed by using the Server Properties (Database Settings Page) in Management Studio. Changing the default path requires restarting SQL Server.
爲什麼,當我嘗試了上面的查詢,我得到一個錯誤:
File option FILENAME is required in this CREATE/ALTER DATABASE statement.
除非我誤會是指這裏什麼data file name
。
是 - 您嘗試過嗎?只需使用'CREATE DATABASE MyDb;'和'Enter',並且您的SQL Server上應該有一個名爲'MyDb'的新數據庫...數據庫文件將基於數據庫名稱以及'模型'數據庫 –
我想給自己的邏輯名稱。我已經知道沒有指定任何東西應該在默認路徑上創建數據庫。 – user3832856
正如@DanGuzman在他的回答中解釋的那樣,如果你指定了*邏輯名*,那麼你必須指定文件名 - 沒有辦法指定邏輯名 - 根本沒有任何方法,或者兩者都沒有 –