-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate.sql
More file actions
42 lines (30 loc) · 954 Bytes
/
create.sql
File metadata and controls
42 lines (30 loc) · 954 Bytes
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
create DATABASE Masroka;
Create Table Account(
UserName int Primary Key, #edited to varchar(50)
Pass varchar(50),
Email varchar(50)
);
Alter Table account modify column UserName varchar(50);
create Table Post(
text varchar(100),
PostID int primary key,
foundsth boolean,
UserName varchar(50),
FOREIGN KEY (UserName) REFERENCES Account (UserName)
);
create Table comment(
text varchar(100),
commentid int primary key,
UserName varchar(50),
FOREIGN KEY (UserName) REFERENCES Account (UserName),
PostID int,
FOREIGN KEY (PostID) REFERENCES Post (PostID)
);
insert into account values("amr","7263","email");
select * from account;
delete from account;
select * from account where UserName = "amr" and Pass = "7263115";
Alter table comment drop foreign key comment_ibfk_2;
Alter Table Post modify postID int auto_increment;
Alter table comment add constraint comment_post_fk foreign key (UserName) references Post(UserName);
select * from Post;