データ・マイニング-mysql
3290 ワード
mysqlの一般的なコマンド
ライブラリのアクション
データベースの作成:
データベースの削除:
テーブルの操作
テーブルを作成します.
テーブル列のフォーマットの変更
表のスタイルの表示
テーブルを削除するには
データの操作、添削
データの追加
データの削除
データの変更
データを調べる
単一テーブルクエリ
マルチテーブルクエリ
ビューアクション
仮想テーブル、クエリー結果に依存して、クエリー・テーブルのデータが変更され、ビュー・データが変更されます.
取引アクション
トランザクション属性:原子間(A):トランザクションは最小単位であり、再分割不可(C):トランザクションがすべてのDML文の操作を要求する場合、同時に成功または同時に失敗する独立性(I):トランザクションAとトランザクションBの間に独立性持続性(D):トランザクションの保証、トランザクションの終了フラグ(メモリのデータがハードディスクファイルに永続する)
オープントランザクション:Start Transactionトランザクション終了:End Transactionコミットトランザクション:Commit Transactionロールバックトランザクション:Rollback Transaction
ライブラリのアクション
データベースの作成:
create database newsdb;
データベースの削除:
drop database newsdb;
テーブルの操作
テーブルを作成します.
create table `news` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`title` varchar(100) NOT NULL,
`username` varchar(20) NOT NULL,
`content` text,
`submitTime` datetime default NULL,
`viewCount` int(10) unsigned default NULL,
`catalogs` varchar(20) default NULL,
`attachment` varchar(100) default NULL,
PRIMARY KEY (`id`));
テーブル列のフォーマットの変更
alter table news modify id integer not null, change title varchar(200);
表のスタイルの表示
desc news;
テーブルを削除するには
drop table news;
データの操作、添削
データの追加
insert into `news` (`id`,`title`,`username`,`content`,`submittime`,`viewcount`,`catalogs`,`attachment`)
values (1,' ',' ',' ','2009-12-14 00:00:00',1,'5','null');
データの削除
delete from news where id=1;
データの変更
update table news set title = “ ” ;
データを調べる
単一テーブルクエリ
select*from [where ];
eg:select*from students;// students ,
select field1,field2,...fieldn... from [where ];
eg:select id,name,age from students;// students , id,name,age
select distinct from ;
eg: select distinct name from students;// ;
select distinct name,age from students;//
1.distinct
2.distinct 。 ---- sidtinct name,age , id , , name,age .
3.distinct , : 。
where
select from where ;
eg:select * from student where sex=' ' and age>20; // , 20 。
where >、=、<=、!= , or、and
select * from [where ] [ order by field1 [desc/asc],field2 [desc/asc]... ] limit 5;
eg:select *from student order by age desc limit 5;// 。
1.desc ,asc
2.order by , 。
3. , 。
4. , 。
select fun_name from [where ] [group by field1,field2...] [with rollup] [having ];
eg:
1.fun_name , , : sum( )、count(*)( )、max( )、min( )。
2.group by 。 , group by 。
3.having 。
マルチテーブルクエリ
:
select staff.name,deptname from staff left join deptno on staff.name=deptno.name;
: , ,
select staff.name,deptname from staff left join deptno on staff.name=deptno.name;
ビューアクション
仮想テーブル、クエリー結果に依存して、クエリー・テーブルのデータが変更され、ビュー・データが変更されます.
create view data as select....
取引アクション
トランザクション属性:原子間(A):トランザクションは最小単位であり、再分割不可(C):トランザクションがすべてのDML文の操作を要求する場合、同時に成功または同時に失敗する独立性(I):トランザクションAとトランザクションBの間に独立性持続性(D):トランザクションの保証、トランザクションの終了フラグ(メモリのデータがハードディスクファイルに永続する)
オープントランザクション:Start Transactionトランザクション終了:End Transactionコミットトランザクション:Commit Transactionロールバックトランザクション:Rollback Transaction