-
생활코딩( Database2 MySQL ) (8) - CRUD of DeleteBackend/MYSQL 2021. 6. 2. 14:05
1. Delete
다음의 syntax를 사용
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name [PARTITION (partition_name [, partition_name] ... )] [WHERE where_condition] [ORDER BY ... ] [LIMIT row_count]
1-1) SQL script
-- use opentutorials schema. USE opentutorials; -- see topics table. SELECT * FROM topic; -- delete unwanted row data DELETE FROM topic WHERE title='Egoin'; -- show topics for delete check SELECT * FROM topic;
1) WHERE 문을 사용하지 않으면 전부 data 삭제해버리므로 반드시 WHERE문을 작성
1-2) output before
+----+---------------+---------------------+---------------------+---------+-------------+ | id | title | description | created | author | profile | +----+---------------+---------------------+---------------------+---------+-------------+ | 1 | MySQL | MySQL is... | 2021-05-31 22:31:50 | HJ Yang | developer | | 2 | MySQL | MySQL is... | 2021-05-31 22:34:53 | HJ Yang | developer | | 3 | MySQL | MySQL is... | 2021-05-31 22:35:47 | HJ Yang | developer | | 4 | MySQL | MySQL is... | 2021-05-31 23:06:02 | HJ Yang | developer | | 5 | SQL Server | SQL Server is... | 2021-05-31 23:06:02 | duruwa | data admin | | 6 | Egoin | Egoing is... | 2021-06-01 23:48:46 | Unknown | creator | | 7 | Mongus Server | Mongus Server is... | 2021-06-01 23:48:46 | Admin | is admin... | +----+---------------+---------------------+---------------------+---------+-------------+ 7 rows in set (0.00 sec) Query OK, 1 row affected (0.01 sec)
1-3) output after
+----+---------------+---------------------+---------------------+---------+-------------+ | id | title | description | created | author | profile | +----+---------------+---------------------+---------------------+---------+-------------+ | 1 | the MySQL | new MySQL is... | 2021-05-31 22:31:50 | HJ Yang | developer | | 2 | the MySQL | new MySQL is... | 2021-05-31 22:34:53 | HJ Yang | developer | | 3 | the MySQL | new MySQL is... | 2021-05-31 22:35:47 | HJ Yang | developer | | 4 | the MySQL | new MySQL is... | 2021-05-31 23:06:02 | HJ Yang | developer | | 5 | SQL Server | SQL Server is... | 2021-05-31 23:06:02 | duruwa | data admin | | 7 | Mongus Server | Mongus Server is... | 2021-06-01 23:48:46 | Admin | is admin... | +----+---------------+---------------------+---------------------+---------+-------------+ 6 rows in set (0.00 sec)
참조
https://opentutorials.org/course/3161/19542
반응형'Backend > MYSQL' 카테고리의 다른 글
생활코딩( Database2 MySQL ) (10) - Relational Database(2) (0) 2021.06.02 생활코딩( Database2 MySQL ) (9) - Relational Database(1) (0) 2021.06.02 생활코딩( Database2 MySQL ) (7) - CRUD of Update (0) 2021.06.02 생활코딩( Database2 MySQL ) (6) - CRUD of Select (0) 2021.06.02 생활코딩( Database2 MySQL ) (5) - CRUD of Insert (0) 2021.05.31