-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.sql
More file actions
38 lines (31 loc) · 841 Bytes
/
messages.sql
File metadata and controls
38 lines (31 loc) · 841 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
use message_board;
drop table if exists messages;
create table messages(
id int unsigned primary key auto_increment,
content varchar(500) not null,
username char(20) not null,
create_datetime datetime
default current_timestamp not null,
update_datetime timestamp
default current_timestamp not null
on update current_timestamp
);
ALTER TABLE messages
Change user_name username char(20);
select * from messages
where update_datetime > '2019-03-17 03:21:54'
order by update_datetime desc
limit 30
offset 20
;
select id,content,username,
create_datetime,
update_datetime
from messages limit 10 offset 2;
insert into messages(content, username)
values ('hello world, this is first message', 'Jon');
select
id,content,username,update_datetime
from messages
order by create_datetime
limit 3 offset 3;