- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate-database.sql
More file actions
Latest commit
34 lines (28 loc) · 789 Bytes
/
Copy pathcreate-database.sql
File metadata and controls
34 lines (28 loc) · 789 Bytes
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
-- write your queries here
-- Create a new database called 'SimpleDB'
-- Connect to the 'master' database to run this snippet
USEmaster
GO
-- Create the new database if it does not exist already
IFNOTEXISTS (
SELECTname
FROMsys.databases
WHEREname=N'SimpleDB'
)
CREATEDATABASESimpleDB
GO
USE SimpleDB
GO
-- Create a new table called 'customers' in schema 'dbo'
-- Drop the table if it already exists
IFOBJECT_ID('dbo.customer', 'U') ISNOTNULL
DROPTABLEdbo.customers
GO
-- Create the table in the specified schema
CREATETABLEdbo.customers (
customerId INTNOTNULLPRIMARYKEY, -- primary key column
cust_name [NVARCHAR](30) NOTNULL,
cust_address [NVARCHAR](80) NOTNULL
-- specify more columns here
);
GO