Mysql基本文
1.safe-updatesモードでは、プライマリキー以外の条件でupdateなどを実行できなくなる
2.テーブルの作成
3.すべてのデータを問い合わせる
4.テーブルの内容をクリア
5.次にn組のデータを取得する
6.自増データ照会(以前調べたデータへの照会を防止)
7.データの挿入
8.自増分フィールドをあるシーケンス番号から指定する
9.指定された条件に従って削除されたデータ
10テーブルに新しいフィールドを追加
11インデックスをテーブルに追加
12プライマリ・キーの追加
13取得システム現在時間:now()
SET SQL_SAFE_UPDATES = 0
2.テーブルの作成
create table common.qc_question(
qc_type int(10) NOT NULL,
qc_id int NOT NULL AUTO_INCREMENT,
qc_describe VARCHAR(1255) NOT NULL,
qc_answer VARCHAR(255) NOT NULL,
PRIMARY KEY ( qc_id )
);
3.すべてのデータを問い合わせる
select * from common.qc_question
4.テーブルの内容をクリア
truncate table common.qc_question
5.次にn組のデータを取得する
select qc_describe,qc_answer from common.qc_question where qc_type = 1 and qc_id >=
(select floor( max(qc_id) * rand()) from test_qc.qc_question ) order by qc_id limit n
6.自増データ照会(以前調べたデータへの照会を防止)
select qc_id,qc_describe, qc_answer from common.qc_question where qc_type = 1 limit 2 offset n*2(n )
7.データの挿入
insert into common.question values(qc_type,null,"qc_describe","qc_answer")
8.自増分フィールドをあるシーケンス番号から指定する
alter table qc.qc_question AUTO_INCREMENT=55;
9.指定された条件に従って削除されたデータ
delete from qc.qc_question where qc_id >= 55
10テーブルに新しいフィールドを追加
alter table table1( ) add transactor( ) varchar(10) not Null
11インデックスをテーブルに追加
alter table test.test1 add index index_test1(uid) :index_test1
create index index_test2 on test.test1(trans) : index_test2
12プライマリ・キーの追加
Alter table tb add primary key(id);
13取得システム現在時間:now()