C-log

🗃️나의 SQL : DELETE 본문

DB/🐬MySQL

🗃️나의 SQL : DELETE

4:Bee 2023. 9. 11. 12:24
728x90

MariaDB [opentutorials]> SELECT * FROM topic;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title      | description       | created             | author | profile                   |
+----+------------+-------------------+---------------------+--------+---------------------------+
|  1 | MySQL      | MySQL is ...      | 2023-09-10 15:36:30 | egoing | developer                 |
|  2 | Oracle     | Oracle is ...     | 2023-09-10 15:51:16 | egoing | developer                 |
|  3 | SQL Server | SQL Server is ... | 2023-09-10 15:57:25 | duru   | data administrator        |
|  4 | PostgreSQL | PostgreSQL is ... | 2023-09-10 15:58:31 | taeho  | data scientist, developer |
|  5 | MongoDB    | MongoDB is ...    | 2023-09-10 15:59:20 | egoing | developer                 |
+----+------------+-------------------+---------------------+--------+---------------------------+
5 rows in set (0.000 sec)

 

지난 시간의 우리의 스키마는 위의 모습을 하고 있다. 우리는 UPDATE를 배웠으니 이제 삭제하는 방법을 배워 보려고 한다.  아래 코드를 보자.

DELETE FROM topic WHERE id = 5;

MariaDB [opentutorials]> DELETE FROM topic WHERE id = 5;
Query OK, 1 row affected (0.004 sec)

MariaDB [opentutorials]> SELECT * FROM topic;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title      | description       | created             | author | profile                   |
+----+------------+-------------------+---------------------+--------+---------------------------+
|  1 | MySQL      | MySQL is ...      | 2023-09-10 15:36:30 | egoing | developer                 |
|  2 | Oracle     | Oracle is ...     | 2023-09-10 15:51:16 | egoing | developer                 |
|  3 | SQL Server | SQL Server is ... | 2023-09-10 15:57:25 | duru   | data administrator        |
|  4 | PostgreSQL | PostgreSQL is ... | 2023-09-10 15:58:31 | taeho  | data scientist, developer |
+----+------------+-------------------+---------------------+--------+---------------------------+
4 rows in set (0.000 sec)

이제 우리는 CRUD의 모든 부분을 할 수 있게 되었다.

728x90
Comments