0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【CRUD】SQL基本構文 なぜか入力されない時に見るやつ

Posted at

CRUD・・・CREATE READ UPDATE DELETE の略。

【CREATEの書き方】
CREATE TABLE テーブル名 (列名1 型 制約, 列名2 型 制約);

【READの書き方】
SELECT * FROM テーブル名;
→ テーブル内情報を全件取得

SELECT 列名1, 列名2 FROM テーブル名;
→ テーブル内情報を列名指定で全件取得

SELECT 列名 FROM テーブル名 WHERE 検索条件;
→列名指定かつ検索条件で取得するものを選んで取得

【UPDATEの書き方】
UPDATE テーブル名 SET 列名 = 更新データ WHERE 条件;
例) UPDATE tbl SET a1 = 'AAA', a2 = 'BBB' WHERE quality = 'Na';

解説
tblテーブルに置いてquality列が Na の行に関して、
a1列とa2列をそれぞれ AAA と BBB に更新しますよ~

【DELETEの書き方】
DELETE FROM テーブル名 WHERE 条件;
→行を削除したいときに使用。ちなみに、テーブルを削除したいときはDROP。

DROP TABLE テーブル名;
→で消えるど。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?