-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_DDL and Contraints.sql
More file actions
68 lines (55 loc) · 1.63 KB
/
SQL_DDL and Contraints.sql
File metadata and controls
68 lines (55 loc) · 1.63 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--create database Authorization.
--create table department where columns include dep_no,dep_name,location.
--create table employee where columns include empno,emp_name,job,mgr,hiredate.
--alter table employee and Add columns salary, commission, deptno.
--Drop Column location from Department table
--Delete all record from Employee table
--Drop Department Table.
--CREATE TABLE StarsIn ( movieTitle char(30), movieYear int,starName char(30) );
--Add a column ‘Address’ in Starsin table in database Authorization.
create Database Authorize;
use Authorize;
create table Department (
dep_no int identity(1,1) Primary key Not NULL,
dep_name varchar(255) Not Null,
loc varchar(255) Not Null
);
create table Employee (
emp_no int identity(1,1) Primary key Not NULL,
emp_name varchar(255) Not Null,
HireDate Date Not Null,
job varchar(20),
mgr decimal(4,0) Not NULL
);
alter Table Employee
Add salary money, commission money,
dep_no int ,
Foreign Key (dep_no) references Department(dep_no);
Alter table Department
Drop column loc
Truncate table Employee
create Table StarsIn(
movieTitle char(30) Not Null,
movieYear int,
starName char(30)
);
Alter table StarsIn
Add Address varchar(250);
create Table Customers(
Customer_id int Primary key,
FirstName varchar(255),
LastName varchar(255),
City varchar(255) default 'Karachi',
Address varchar(255),
Constraint check_City Check (City='Karachi' or City='Lahore')
);
create Table Orders(
Order_ID int Primary key,
Customer_ID int,
Order_Details varchar(255),
Order_Date date,
Required_Date date,
Foreign Key (Customer_ID) references Customers(Customer_ID)
);
Alter table Customers
Add CNIC char(15) unique NOT NULL