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.

僕なりの MySQL 備忘録

Last updated at Posted at 2024-05-16

出力

見やすく

select * from table_name\G

新しい方から表示する

select * form table_name order by id desc limit 4;

ファイルに書き出し

※以下はroot権限がないとできないこともある。

SELECT フィールド名 FROM テーブル名 INTO OUTFILE 'ファイル名'
echo 'select <field> from <table>' | mysql -u user -p db > ./test.dmp

カラム

追加

ALTER TABLE テーブル名 ADD COLUMN 新規カラム名 型情報 before `colomnName`;

mysqlのバージョンによってbefore/afterが使えないときがあるかも?

削除

ALTER TABLE [テーブル名] DROP COLUMN [フィールド名];

名前変更

ALTER TABLE tbl_name CHANGE COLUMN old_col_name new_col_name column_definition;

定義変更

ALTER TABLE tbl_name MODIFY col_name column_definition;

データ

データの入力

INSERT INTO tbl_name (``,``) VALUES ('','');

データのアップデート

UPDATE tbl_name SET ``='', ``='' WHERE `` = ;

データの削除

DELETE FROM tbl_name WHERE `` = ;
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?