forked from SeemaSP/shoppingjquerycart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2 - Working with schemas.sql
50 lines (33 loc) · 1.37 KB
/
2 - Working with schemas.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- Demonstration 2 - Working with Schemas
-- Step 1: Open a query window to the SQLTraining database
USE SQLTraining;
GO
-- Step 2: Create a schema
CREATE SCHEMA Reportingseemap AUTHORIZATION dbo;
GO
-- Step 3: Create a schema with an included object
CREATE SCHEMA Operationsseemap AUTHORIZATION dbo
CREATE TABLE Flightsseemap (FlightID int IDENTITY(1,1) PRIMARY KEY,
Origin nvarchar(3),
Destination nvarchar(3));
GO
-- Step 4: Use object explorer to work out which schema
-- the table has been created in
-- Step 5: Drop the table
DROP TABLE Operationsseemap.Flightsseemap;
GO
-- Step 6: Drop the schema
DROP SCHEMA Operationsseemap;
GO
-- Step 7: Use the same syntax but execute each part of the
-- statement separately
CREATE SCHEMA Operationsseemap AUTHORIZATION dbo
CREATE TABLE Flightsseemap (FlightID int IDENTITY(1,1) PRIMARY KEY,
Origin nvarchar(3),
Destination nvarchar(3));
-- Step 8: Again, use object explorer to work out which schema
-- the table has been created in
-- Step 9: Create the same table in a different schema:allowed
CREATE TABLE Reportingseemap.Flightsseemap (FlightID int IDENTITY(1,1) PRIMARY KEY,
Origin nvarchar(3),
Destination nvarchar(3));