์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- JS #ํ๋ก์ ํธ
- slow and steady
- Project
- ๋น๋๊ธฐ
- json
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- js
- object
- Import
- setTimeout()
- Porject
- mysql
- callback
- db
- await
- ์ฐธ๊ณ ๋ธ๋ก๊ทธ
- addEventListener
- execCommand
- sql
- ajax
- prj
- ๋๊ธฐ
- https://m.blog.naver.com/tt2t2am1118/221010125300
- async
- ๊ฒ์
- eport
- database
- webpack
- promise
- ํผํ
- Today
- Total
C-log
๐๏ธ๋์ SQL : ๊ด๊ณํ ๋ฐ์ดํฐ์ ์์-ํ ์ด๋ธ ๋ถ๋ฆฌํ๊ธฐ ๋ณธ๋ฌธ
๐๏ธ๋์ SQL : ๊ด๊ณํ ๋ฐ์ดํฐ์ ์์-ํ ์ด๋ธ ๋ถ๋ฆฌํ๊ธฐ
4:Bee 2023. 9. 12. 00:26์ฐ๋ฆฌ๊ฐ ๊ด๊ณํ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด์๋ TABLE์ ๋ถ๋ฆฌํด์ผํ๋ค. ๊ทธ๋์ ๊ธฐ์กด์ TABLE์ ๋ช ์นญ์ ๋ณ๊ฒฝํด์ ์๋ก ์ ์ฅํ ๊ฒ์ด๋ค. ์๋ ์ฝ๋๋ฅผ ์ดํด๋ณด์.
RENAME TABLE topic TO topic_backup;
MariaDB [opentutorials]> RENAME TABLE topic TO topic_backup;
Query OK, 0 rows affected (0.018 sec)
MariaDB [opentutorials]> SHOW TABLES;
+-------------------------+
| Tables_in_opentutorials |
+-------------------------+
| topic_backup |
+-------------------------+
1 row in set (0.001 sec)
์ดํ ์ฐ๋ฆฌ๋ ์ ์ ์ฌ์ฉํ๋ topic์ด๋ TABLE์ ์๋ก์ด ํํ๋ก ์์ฑํ ๊ฒ์ด๋ค. ์๋ ์ฝ๋๋ฅผ ์ดํด๋ณด๋ฉฐ ๊ธฐ์กด TABLE์ ๋น๊ตํด๋ณด์.
CREATE TABLE topic(-);
MariaDB [opentutorials]> CREATE TABLE topic (
-> id int(11) NOT NULL AUTO_INCREMENT,
-> title varchar(30) NOT NULL,
-> description text,
-> created datetime NOT NULL,
-> author_id int(11) DEFAULT NULL,
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.017 sec)
topic_backup TABLE ๊ณผ topic TABLE ๋น๊ต
MariaDB [opentutorials]> DESC topic_backup;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| description | text | YES | | NULL | |
| created | datetime | NO | | NULL | |
| author | varchar(30) | YES | | NULL | |
| profile | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.025 sec)
MariaDB [opentutorials]> DESC topic;
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(30) | NO | | NULL | |
| description | text | YES | | NULL | |
| created | datetime | NO | | NULL | |
| author_id | int(11) | YES | | NULL | |
+-------------+-------------+------+-----+---------+----------------+
5 rows in set (0.024 sec)
๋ง์ง๋ง์ผ๋ก ์ฐ๋ฆฌ๊ฐ topic์์ author_id๊ฐ ์ฐธ์กฐํ TABLE์ ์์ฑํ ๊ฒ์ด๋ค. ์๋ ์ฝ๋๋ฅผ ์ดํด๋ณด์
CREATE TABLE author(-);
MariaDB [opentutorials]> CREATE TABLE author (
-> id int(11) NOT NULL AUTO_INCREMENT,
-> name varchar(20) NOT NULL,
-> profile varchar(200) DEFAULT NULL,
-> PRIMARY KEY (id)
-> );
MariaDB [opentutorials]> DESC author;
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| profile | varchar(200) | YES | | NULL | |
+---------+--------------+------+-----+---------+----------------+
3 rows in set (0.023 sec)
์ฐ๋ฆฌ๊ฐ ์ด์ ๋ฐ์ดํฐ๋ฅผ ์ฐธ์กฐํ๊ธฐ ์ํด์๋ ์์ ๊ฐ์ด ์ธํฐํ์ด์ค๋ฅผ ์ค์ ํด๋์ผ ํ๋ค.
๋ฐ์ดํฐ ๊ฐ
INSERT INTO topic(-) VALUES(-);
MariaDB [opentutorials]> INSERT INTO topic(id, title, description, created, author_id)
VALUES(1, 'MySQL', 'MySQL is...', '2018-1-1 12:10:11', 1);
Query OK, 1 row affected (0.004 sec)
MariaDB [opentutorials]> INSERT INTO topic(id, title, description, created, author_id)
VALUES(2, 'Oracle', 'Oracle is...', '2018-1-03 13:01:10', 1);
Query OK, 1 row affected (0.002 sec)
MariaDB [opentutorials]> INSERT INTO topic(id, title, description, created, author_id)
VALUES(3, 'SQL Server', 'SQL Server is...', '2018-01-20 11:01:10', 2);
Query OK, 1 row affected (0.004 sec)
MariaDB [opentutorials]> INSERT INTO topic(id, title, description, created, author_id)
VALUES(4, 'PostgreSQL', 'PostgereSQL is...', '2018-01-23 1:3:3', 3);
Query OK, 1 row affected (0.005 sec)
MariaDB [opentutorials]> INSERT INTO topic(id, title, description, created, author_id)
VALUES(5, 'MongoDB', 'MongoDB is...', '2018-01-30 12:31:3', 1);
Query OK, 1 row affected (0.004 sec)
MariaDB [opentutorials]> SELECT * FROM topic;
+----+------------+-------------------+---------------------+-----------+
| id | title | description | created | author_id |
+----+------------+-------------------+---------------------+-----------+
| 1 | MySQL | MySQL is... | 2018-01-01 12:10:11 | 1 |
| 2 | Oracle | Oracle is... | 2018-01-03 13:01:10 | 1 |
| 3 | SQL Server | SQL Server is... | 2018-01-20 11:01:10 | 2 |
| 4 | PostgreSQL | PostgereSQL is... | 2018-01-23 01:03:03 | 3 |
| 5 | MongoDB | MongoDB is... | 2018-01-30 12:31:03 | 1 |
+----+------------+-------------------+---------------------+-----------+
5 rows in set (0.001 sec)
INSERT INTO author (-) VALUES(-);
MariaDB [opentutorials]> INSERT INTO author (id, name, profile)
VALUES(1, 'egoing', 'developer');
Query OK, 1 row affected (0.003 sec)
MariaDB [opentutorials]> INSERT INTO author (id,name,profile)
VALUES(2, 'duru', 'data administrator');
Query OK, 1 row affected (0.003 sec)
MariaDB [opentutorials]> INSERT INTO author (id,name,profile)
VALUES(3, 'taeho', 'data scientist, developer');
Query OK, 1 row affected (0.003 sec)
MariaDB [opentutorials]> SELECT * FROM author;
+----+--------+---------------------------+
| id | name | profile |
+----+--------+---------------------------+
| 1 | egoing | developer |
| 2 | duru | data administrator |
| 3 | taeho | data scientist, developer |
+----+--------+---------------------------+
3 rows in set (0.000 sec)
'DB > ๐ฌMySQL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐๏ธ๋์ SQL : ๋ณต์ต์ ํ์! (0) | 2023.09.19 |
---|---|
๐๏ธ๋์ SQL : JOIN (0) | 2023.09.15 |
๐๏ธ๋์ SQL : DELETE (0) | 2023.09.11 |
๐๏ธ๋์ SQL : UPDATE (0) | 2023.09.11 |
๐๏ธ๋์ SQL : SELECT (0) | 2023.09.10 |