-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 4.txt
More file actions
50 lines (45 loc) · 1.36 KB
/
Day 4.txt
File metadata and controls
50 lines (45 loc) · 1.36 KB
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
create table people(first_name varchar(20), last_name varchar(20), age int);
desc people;
insert into people(first_name, last_name, age)
values('Bob', 'Belcher', 42);
select * from people;
insert into people(first_name, last_name, age)
values('Tina', 'Lim', 34),
('Raj', 'Singh', 17),
('Dae', 'Ro', 28);
drop table people;
show tables;
-- insert into cats(name, age)
-- values('I know a Cat that lives near my house. Her color uis black and white and she often likes to sleep on the chair in my garden.', 1);
desc cats;
insert into cats(name) values('Alabama');
select * from cats;
insert into cats() values();
-- To prevent age is not null
create table cats2(
name varchar(100) not null,
age int not null
);
desc cats2;
insert into cats2(name) values('Texas');
select * from cats2;
-- default values
create table cats3(
name varchar(20) default 'no name provided',
age int default 99
);
desc cats3;
insert into cats3(age) values(13);
select * from cats3;
insert into cats3() values();
select * from cats3;
insert into cats3(name, age) values('Bob', null);
select * from cats3;
create table cats4(
name varchar(100) not null default 'unnamed',
age int not null default 99
);
-- Below will given an error
insert into cats4(name, age) values('Cali', null);
--as we have defined age as not null
-- learned some new command will add later, this is just for today's commit :)