Sei sulla pagina 1di 2

create database xyz

use abc
go
create table Sports(
Department_ID int identity(101,1) not null primary key
,First_Name varchar(15)
,Last_Name varchar(15)
,DOB date not null
,city varchar(10)
,State char(2)
,Zip numeric(5,0)
)
CREATE TABLE CUSTOMER
(Customer_Id int NOT NULL PRIMARY KEY
,LastName varchar(25) NOT NULL
,FirstName varchar(25)
,Address varchar(25)
,City varchar(25)default 'LIC'
,ZIPCODE int default 11101)
CREATE TABLE ORDERS
(Order_Id int NOT NULL PRIMARY KEY
,OrderNo int NOT NULL
,Orders_Quantity int
,Price Numeric (18,2)
,Customer_ID int FOREIGN KEY REFERENCES Customer (Customer_Id)
)
CREATE TABLE ORDERDETAILS
(OrderDetails_ID int NOT NULL PRIMARY KEY
,Order_Number int NOT NULL
,Order_Date date default GETDATE()
,Item_ID Int NOT NULL UNIQUE
,Order_ID int Foreign Key REFERENCES Orders (Order_ID)
)
insert into Sports(First_Name,Last_Name,DOB,city,State,Zip)
values('Abdus','Salam','01-01-1970','Queens','NY',11372)
insert into Sports values('Abdul','Mannan','01-01-1980',
'Queens','NY',11372)
Update Sports
set First_Name='MD'
where Department_ID=102
insert into Sports values('Abdul','Jaman','01-01-1960',
'Queens','NY',11372)

delete from Sports


where Department_ID=103
exec Sp_Rename 'Sports.Address','City', 'Column'

exec Sp_Rename 'Sports','Department'


exec Sp_Rename 'Department','Sports'