6

 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
USE master;
GO
IF db_id (N'Bank_lab6') IS NOT NULL
DROP DATABASE Bank_lab6;
go
CREATE DATABASE Bank_lab6
ON (NAME = Bank_dat_lab6, FILENAME = 'C:\data\Bankdatlab6.mdf',
SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = 5MB)
LOG ON (NAME = Bank_log_lab6, FILENAME = 'C:\data\Bankloglab6.ldf',
SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB);
GO
USE Bank_lab6;
GO
CREATE TABLE Human (idofperson int IDENTITY(0, 1) PRIMARY KEY,
firstname char(50),
secondname char(50),
location char(150),
phone int);
GO
ALTER TABLE Human ADD age int CHECK (age > 0);
GO
ALTER TABLE Human ADD email char(25) DEFAULT ('н/д');
GO
ALTER TABLE Human ADD dateofbirth datetime DEFAULT (getdate());
GO
CREATE TABLE Employee (uniqid uniqueidentifier PRIMARY KEY ROWGUIDCOL DEFAULT (newid()),
post char(50),
passnumber int,
experience int);
GO
CREATE TABLE Client (clientid int PRIMARY KEY,
accountnumber int);
GO
CREATE SEQUENCE ForClient START WITH 0 INCREMENT BY 1;
GO
INSERT Client (clientid, accountnumber)
VALUES (NEXT VALUE FOR ForClient, 1);
INSERT Client (clientid, accountnumber)
VALUES (NEXT VALUE FOR ForClient, 2);
GO
/*
SELECT * FROM Client;
GO
*/
CREATE TABLE Operation (idoper int PRIMARY KEY,
date datetime);
GO
CREATE TABLE Credit (idoper int FOREIGN KEY REFERENCES Operation(idoper)
ON DELETE SET NULL
ON UPDATE CASCADE,
sumofmoney int,
procent int);
GO