mysql.server start
mysql_secure_installation
mysql -uroot -p
reate database node242 default character set utf8;
use node242
mysql> create table topic(
-> id int(11) not null auto_increment,
-> title varchar(100) not null,
-> description TEXT null,
-> created DATETIME not null,
-> author varchar(30) null,
-> profile varchar(100) null,
-> primary key(id))
show tables
desc topic;
insert into topic(title, description, created, author, profile) values('javascript','javascript is...', now(), 'KIS','developer');
insert into topic(title, description, created, author, profile) values('C++','C++ is...', now(), 'KIS','developer');
insert into topic(title, description, created, author, profile) values('Python','Python is...', now(), 'Lee','teacher');
insert into topic(title, description, created, author, profile) values('Nodejs','Nodejs is...', now(), 'Kim','developer');
insert into topic(title, description, created, author, profile) values('Mysql','Mysql is...', now(), 'Park','DBmanager');
select * from topic;
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
| 5 | Mysql | Mysql is... | 2022-05-20 16:59:32 | Park | DBmanager |
+
select * from topic where profile="developer";
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
+
select * from topic order by id desc
+
| id | title | description | created | author | profile |
+
| 5 | Mysql | Mysql is... | 2022-05-20 16:59:32 | Park | DBmanager |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
+
select * from topic order by title;
+
| id | title | description | created | author | profile |
+
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 5 | Mysql | Mysql is... | 2022-05-20 16:59:32 | Park | DBmanager |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
+
select * from topic order by id asc limit 2;
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
+
update topic set description ='database is...' where id=5;
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
| 5 | Mysql | database is... | 2022-05-20 16:59:32 | Park | DBmanager |
+
update topic set title ='Database' where id=5;
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
| 5 | Database | database is... | 2022-05-20 16:59:32 | Park | DBmanager |
+
delete from topic where id=5;
+
| id | title | description | created | author | profile |
+
| 1 | javascript | javascript is... | 2022-05-20 16:52:30 | KIS | developer |
| 2 | C++ | C++ is... | 2022-05-20 16:56:54 | KIS | developer |
| 3 | Python | Python is... | 2022-05-20 16:57:39 | Lee | teacher |
| 4 | Nodejs | Nodejs is... | 2022-05-20 16:58:44 | Kim | developer |
+