検索条件
全7件
(2/2ページ)
***_database
***_db
xxx_db
yyy_db
***_table
***_tbl
xxx_table
yyy_table
***_field
***_fld
***_column
***_clm
xxx_field
yyy_field
select * from xxx_tbl as x order by `x`.xxx_fld;
↓
select * from xxx_tbl as x order by x.xxx_fld;
> SELECT * FROM ***_table; > Select * From ***_table; > select * from ***_table;サンプルは小文字で書いている。
> select * from xxx_table where xxx_field = "0" ;
> create table xxx_table ( aaa_field int unsigned not null auto_increment primary key);いろいろ作りたいとき。
> create table xxx_table ( aaa_field int unsigned not null auto_increment primary key, bbb_field int, ccc_field varchar(255), ddd_field tinyint unsigned not null, eee_field datetime default current_timestamp, fff_field datetime on current_timestamp default current_timestamp, ggg_field bit(1) );
> select * from xxx_table;
> select * from xxx_table as x inner join yyy_table as y on x.zzz_id = y.zzz_id;
> select * from xxx_table as x inner join yyy_table as y on x.yyy_id = y.yyy_id inner join zzz_table as z on x.zzz_id = z.zzz_id;
> select x.fld, y.fld from xxx_table as x left outer join yyy_table as y on x.zzz_id = y.yyy_id;
> select x.fld, y.fld from xxx_table as x right outer join yyy_table as y on x.zzz_id = y.yyy_id;
> select x.fld, y.fld from xxx_table as x full outer join yyy_table as y on x.zzz_id = y.yyy_id;
> select * from xxx_table where yyy_id = 2;
> select * from xxx_table where yyy_id = 2 or yyy_id = 3 ;
> select * from ***_table order by ***_field ;
> select * from xxx_table order by xxx_field, yyy_field ;
> select * from ***_table order by ***_field desc ;
> select * from ***_table order by ***_field collate utf8_unicode_ci ;使ったことない
> select * from ***_table order by cast(***_field as char) ;
> insert into xxx_table values ( default, "column", null );
> insert into xxx_table ( xxx_field, yyy_field ) values ( default, "column", null );
update ***_table set field1 = value1;
update ***_table set field1 = value1 where field2 = value2;
update ***_table set xxx_fld = yyy_fld ;
> delete from ***_tableテーブル内全削除(TRUNCATEを使うべき)
where xxx_field = 1;
> delete from ***_table;降順で3つの行を削除
> delete from ***_table
order by xxx_field desc limit 3;
> drop database ***_db;
> use ***_db; > drop table ***_table;
> truncate table ***_table;
> show databases;
> show tables;
> desc ***_table;
> alter table xxx_table alter xxx_field set default "aaaa";
> alter table xxx_table alter xxx_enable set default true;
> alter table ***_table add ***_field integer first;符号なし unsigned の場合の指定
> alter table ***_table add ***_field integer unsigned first;テーブルにデータが追加されたときだけ、タイムスタンプが自動更新されるフィールドの追加
> alter table ***_table add ***_field datetime default CURRENT_TIMESTAMP first;テーブルの、他のフィールドが更新されたときもタイムスタンプが自動更新されるフィールドの追加
> alter table ***_table add ***_field datetime default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP first;
> alter table ***_table add ***_field integer;複数の場合
> alter table ***_table add (xxx_field integer, yyy_field varchar(5));
> alter table ***_table add yyy_field integer after xxx_field;
> alter table ***_table drop column ***_field;
> alter table ***_table modify ***_field integer;Default のあるカラムを Not Null にしたいとき
> alter table ***_table modify ***_field DateTime Not null Default CURRENT_TIMESTAMP;符号なし int 等いろいろ付与したい場合
> alter table ***_table modify ***_field integer unsigned Not null auto_increment;Primary key がないので付与したい場合
> alter table ***_table modify ***_field integer unsigned Not null primary key auto_increment;
> alter table xxx_table change xxx_field yyy_field varchar(1000);
> alter table xxx_table auto_increment = 1;