1
votes

I am new to MS SQL Server, coming from MySQL. I sort of understand MS SQL schemas and their purpose, but I don't see any need for them for small applications with the one DBA.

Is it possible to ignore schemas altogether, for example to create and query tables? If so what would be the format to create a table without specifying a schema? This is in Azure, with an Azure SQL DB.

UPDATE

Thanks to the answer below you don't apparently need to specify a schema when creating a table. Once created, the table will automatically have the schema 'dbo' applied by default.

CREATE TABLE cm_user
(   
cm_user_pk int PRIMARY KEY CLUSTERED, 
user_code VARCHAR(10)  NOT NULL, 
first_name VARCHAR(60)  NOT NULL,
last_name    VARCHAR(60)  NOT NULL,
email    VARCHAR(100)  NOT NULL,
user_type    VARCHAR(20)  NOT NULL     
) 

results in the table dbo.cm_user_pk

1
If by schema you mean 'I don't want to define my columns', then yes you can define a table that just has a VARCHAR(MAX) column and stuff anything you like into it. However it is 100% a bad idea. If you're talking about schemas as in the dbo part of dbo.table, then yes, you don't need to worry about schemas if you don't want. They only give you advantages, but if you can't see any thats fine - Nick.McDermaid
Thanks, yes the OP relates to dbo.table part. Could you post an example as an answer for a query to create the table without the schema part in the dbo? - IlludiumPu36

1 Answers

1
votes

Is it possible to ignore schemas altogether, for example to create and query tables?

I think, it's impossible. When we create a table in Azure SQL database without specify the default schema, the table will have the same schema with the Azure SQL database user.

In Azure SQL database, when a user created, we must specify the schema, the default schema of server admin and user is DBO. That means all the tables created by user will has the same default schema. Please reference:

  1. Logins and Users
  2. CREATE USER (Transact-SQL)
  3. CREATE TABLE (Transact-SQL)

Hope this helps.