My program creates databases and tables at runtime. My understanding of Schema is it is a conceptual folder for multiple databases and databases tables. So I wrote some meaningless code just to test out what schema would do to my code.
My program use SQL Server Authentication instead of Windows Authentication, and create database and tables under the username of TmpUser instead of sa.
If I create a table by CREATE TABLE TmpTable
, I get dbo.TmpTable for table name. If I explicitly type a new schema in CREATE TABLE abc.TmpTable
, I then get the following exception because the schema does not exist:
SqlException: The specify schema name either does not exist or you do not have permission to use it
I went into SSMS and manually create a schema by executing CREATE SCHEMA abc
. SSMS outputs saying the schema of abc has been successfully created. But in SSMS Object Explorer > Security > I see no Schema name nor anything else named abc.
Where is my Schema? If abc was not created, then why was CREATE SCHEMA abc
executed and what did it create?
I went back to Visual Studio and CREATE TABLE abc.TmpTable again, still I receive the same exception.