-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop_Michailidis.txt
110 lines (73 loc) · 1.79 KB
/
drop_Michailidis.txt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-- DROP COMMANDS
-- DROP SEQUENCIES
DROP SEQUENCE seq_borrowers_id;
DROP SEQUENCE seq_authors_id;
-- DROP CONSTRAINTS
-- Check
ALTER TABLE loans
DROP CONSTRAINT ck_loans_return_date;
ALTER TABLE books
DROP CONSTRAINT ck_books_price;
ALTER TABLE books
DROP CONSTRAINT ck_books_n_pages;
ALTER TABLE books
DROP CONSTRAINT ck_books_genre_nn;
ALTER TABLE books
DROP CONSTRAINT ck_books_genre;
ALTER TABLE books
DROP CONSTRAINT ck_books_title;
ALTER TABLE authors
DROP CONSTRAINT ck_authors_gender;
ALTER TABLE authors
DROP CONSTRAINT ck_authors_country;
ALTER TABLE authors
DROP CONSTRAINT ck_authors_date_death;
ALTER TABLE authors
DROP CONSTRAINT ck_authors_lname;
ALTER TABLE authors
DROP CONSTRAINT ck_authors_fname;
ALTER TABLE borrowers
DROP CONSTRAINT ck_borrowers_gender;
ALTER TABLE borrowers
DROP CONSTRAINT ck_borrowers_tel;
ALTER TABLE borrowers
DROP CONSTRAINT ck_borrowers_email;
ALTER TABLE borrowers
DROP CONSTRAINT ck_borrowers_lname;
ALTER TABLE borrowers
DROP CONSTRAINT ck_borrowers_fname;
-- UNIQUE
ALTER TABLE borrowers
DROP CONSTRAINT uk_email;
-- FOREIGN KEYS
ALTER TABLE loans
DROP CONSTRAINT fk_loan_copy;
ALTER TABLE loans
DROP CONSTRAINT fk_loan_borrowers;
ALTER TABLE copies
DROP CONSTRAINT fk_book_isbn;
ALTER TABLE books
DROP CONSTRAINT fk_author_id;
-- PRIMARY KEYS
ALTER TABLE loans
DROP CONSTRAINT pk_loans;
ALTER TABLE copies
DROP CONSTRAINT pk_cop_id;
ALTER TABLE books
DROP CONSTRAINT pk_isbn;
ALTER TABLE authors
DROP CONSTRAINT pk_authors_id;
ALTER TABLE borrowers
DROP CONSTRAINT pk_borrowers_id;
-- DROP TABLES
DROP TABLE loans;
DROP TABLE copies;
DROP TABLE books;
DROP TABLE authors;
DROP TABLE borrowers;
-- Show that they don't exist
SELECT * FROM borrowers;
SELECT * FROM authors;
SELECT * FROM books;
SELECT * FROM copies;
SELECT * FROM loans;