How do I create a SQL table under a different schema?

前端 未结 6 1159
天命终不由人
天命终不由人 2020-12-23 19:59

This is from SQL Server 2008, ssms

When I create a table, it creates under dbo.

I would like to create it under a different schema, but when I use the \'New

6条回答
  •  伪装坚强ぢ
    2020-12-23 20:27

    Shaun F's answer will not work if Schema doesn't exist in the DB. If anyone is looking for way to create schema then just execute following script to create schema.

    create schema [schema_name]
    CREATE TABLE [schema_name].[table_name](
     ...
    ) ON [PRIMARY]
    

    While adding new table, go to table design mode and press F4 to open property Window and select the schema from dropdown. Default is dbo.

    You can also change the schema of the current Table using Property window.

    Refer:

提交回复
热议问题