Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.68 KB | None | 0 0
  1. create table Persons
  2. (
  3.     PersonID int not null identity,
  4.     FirstName varchar(50) not null,
  5.     Salary decimal(18,2) not null,
  6.     PassportID int not null
  7. )
  8.  
  9. insert into Persons (FirstName, Salary, PassportID)
  10. values ('Roberto', 43300.00,102), ('Tom', 56100.00, 103), ('Yana', 60200.00, 101)
  11.  
  12. alter table Persons
  13. add primary key(PersonID)
  14.  
  15. create table Passports
  16. (
  17.     PassportID int not null,
  18.     PassportNumber varchar(50) not null
  19. )
  20.  
  21. insert into Passports (PassportID, PassportNumber)
  22. values (101, 'N34FG21B'), (102, 'K65LO4R7'), (103, 'ZE657QP2')
  23.  
  24. alter table Passports
  25. add primary key(PassportID)
  26.  
  27.  
  28. alter table Persons
  29. add foreign key(PassportID)
  30. references Passports(PassportID)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement