LoginSignup
3
3

More than 5 years have passed since last update.

MySQLコマンドのほんの一部

Posted at

カラムの順番変更

alter table テーブル名 modify 順番を変えたいカラム名 データ型 after 既存のカラム名;

ファイルに記述されたSQL文を実行してデータ投入

source ファイル名;

テーブルからのレコードエクスポート(カラム指定、svc形式)

select カラム名 from テーブル名 into outfile 'ファイル名' fields terminated by ',';

インポート

load data local infile 'ファイル名' ignore into table テーブル名 fields terminated by ',' (カラム名);

timestamp型カラムから指定時間帯のデータ検索

select * from テーブル名 where cast(UDTIME as datetime) between "2014-11-30 10:00:00" and "2014-11-30 10:30:00" limit 10;

sql出力解析

EXPLAIN SELECT * FROM テーブル名 WHERE テーブル名 NOT IN ( SELECT テーブル名
FROM テーブル名 );

テーブルから別テーブルへレコード挿入(1000件のデータを挿入)

insert into テーブル名(カラム名) select カラム名 from テーブル名 limit 1000;

インデックス作成

CREATE INDEX インデックス名 ON テーブル名(カラム名);

3
3
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
3
3