Вы находитесь на странице: 1из 2

1)create table customer ( customer_id int constraint cust_pk primary key, customer_name varchar (10) not null, customer_expense

int constraint cust_check check(customer_expense<10000), customer_phone_num int constraint Phone_man unique, customer_dept_id int constraint dept_id_fk foreign key references customer_dept( customer_dept_id) ) 2) create table customer_dept ( customer_dept_id int constraint cu_pk primary key, customer_dept_name varchar(10) ) 3)insert into customer_dept values(300,'Sales') 4) insert into customer values(2,'Kell',386,8888,200) insert into customer values(3,'sher',782,7777,100) insert into customer values(4,'hyar',null,6666,300) insert into customer values(5,'whyb',345,5555,300) insert into customer values(6,'vale',675,4444,200) 4)alter table customer add location varchar(10), gender char(1) 5) alter table customer drop column location,gender 6)alter table customer drop constraint cust_check alter table customer add constraint cust_check check(customer_expense>20000) 7)alter table customer drop constraint cust_check alter table customer add constraint cust_check check(customer_expense<200) 8)displaying error "Violation of UNIQUE KEY constraint 'Phone_man'. Cannot inser t duplicate key in object 'dbo.customer'. " 9)Violation of PRIMARY KEY constraint 'cust_pk'. Cannot insert duplicate key in object 'dbo.customer'. 10)Cannot insert the value NULL into column 'customer_id', table 'etltesting.dbo .customer'; column does not allow nulls. INSERT fails. 11)alter table customer RENAME customer_phone_num to customer_phone_number 12displaying error "Column customer_id is an index column and cannot be modified " 13)alter table emp add constraint phone_un unique 14)displaying error "The object 'dept_id_fk' is dependent on column 'customer_de pt_id'." 15) select * into customer_1 from customer 16)select * into customer_2 from customer where customer_dept_id=200 17)insert into customer (customer_name,customer_id,customer_phone_num,customer_d ept_id) values ('Gopal',10,1234,300) 18)select * into customer_3 from customer

19)delete from customer_3 where customer_dept_id=100 20)select * from sys.objects where name in( 'customer_1', 'customer_2') 21)select * from sys.columns where name ='customer_id' 22)delete from customer_3 23) update customer_2 set customer_name = 'Gopal' where customer_id =2 24) update customer_2 set customer_expense=0 25)select * from customer order by customer_id asc 26)select * from customer order by customer_dept_id desc 27)select customer_dept_id from customer group by customer_dept_id having COUNT( customer_dept_id)>1 28)select * from customer where customer_dept_id =100 29)select * from customer where customer_expense > 300 30)select * from customer where customer_id between 2 and 5 31)select * from customer where customer_dept_id in(100,200),select * from custo mer where customer_dept_id=100 or customer_dept_id =200 32)select * from customer where not(customer_dept_id=100 or customer_dept_id=200 ) 33)select * from customer where customer_dept_id =100 and customer_expense<700 34)select * from customer where customer_dept_id =200 or customer_expense<700 35)select * from customer where customer_expense is null 36)select * from customer where customer_expense is not null 37)select * from customer where customer_name like 'R%' 38)select * from customer where customer_name like '%R%' 39)select * from customer where customer_name like 'Y_' 40)select * from customer where customer_name like '__ar%'

Вам также может понравиться