szubert

Untitled

Oct 14th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.01 KB | None | 0 0
  1. CREATE TABLE customers
  2. (customerid int identity(100,20) not null,
  3. companyname varchar(40) not null,
  4. contactname char(30) null,
  5. address varchar(60) null,
  6. city char(15) null,
  7. phone char(24) unique null,
  8. fax char(24) null,
  9. constraint unique_name unique(companyname),
  10. CONSTRAINT prim_customer PRIMARY KEY (customerid)
  11. );
  12.  
  13. create table orders
  14. (orderid int identity not null PRIMARY KEY,
  15. customerid int not null,
  16. orderdate date default getdate() null,
  17. shippeddate date null,
  18. freight money null,
  19. shipname varchar(40) null,
  20. shipaddress varchar(40) null,
  21. quantity int null,
  22. customer_id int,
  23. CONSTRAINT fk_customer FOREIGN KEY (customer_id)
  24. REFERENCES customers(customerid));
  25.  
  26. alter table orders add shipregion int null;
  27.  
  28. alter table orders alter column shipregion char(8) null;
  29.  
  30. alter table orders drop column shipregion;
  31.  
  32. alter table orders add constraint not_less check(1 < quantity and quantity < 30 );
  33.  
  34. alter table orders drop constraint not_less;
  35.  
  36. exec sp_rename 'customers.city', 'town', 'COLUMN';
Advertisement
Add Comment
Please, Sign In to add comment