Created
June 12, 2012 13:15
-
-
Save s-tajima/2917448 to your computer and use it in GitHub Desktop.
MySQL snipets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#テーブルの初期化 | |
TRUNCATE TABLE tablename; | |
#複数のカラムでユニークキーを張る | |
ALTER TABLE tablename ADD CONSTRAINT UNIQUE (column1, column2); | |
#テーブルにカラムを追加する | |
ALTER TABLE tablename ADD COLUMN columnname rule AFTER columnname; | |
ex.)ALTER TABLE users ADD COLUMN rest_partner_num int NOT NULL DEFAULT 20 AFTER tutorial; | |
#DBのダンプファイルの生成 | |
mysqldump -u root データベース名 > dump.sql | |
mysql -u root データベース名 < dump.sql | |
#カラムの情報を変更する | |
ALTER TABLE table_name CHANGE COLUMN column_title new_column_title rule; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment