mysql數(shù)據(jù)庫基本存儲單元
database -> tables -> column;
登錄
mysql -u[username] -p[password]
退出
mysql> exit;
Database

顯示所有數(shù)據(jù)庫內(nèi)所有database表
mysql> show databases; (sql語句后分號不能省略)創(chuàng)建database表
mysql> create database [database_name];進入并使用某個database表
mysql> use [database_name];顯示當前database下所有tables;
mysql> show tables;刪除數(shù)據(jù)庫
mysql> drop database [database_name];
Table

查看數(shù)據(jù)庫下某個table表下的內(nèi)容
mysql> use [table_name];創(chuàng)建table表
mysql> create table [table_name] (
column_name column_type,
column_name column_type,
column_name column_type
);
Column

下面是對數(shù)據(jù)的一些操作
查看所有數(shù)據(jù)
mysql> select * from Customer;
(下面所有column的名稱都暫定為Customer)插入數(shù)據(jù)
mysql> insert into Customer values("hxn","hxn","beijing","china",null,null);
(不插入數(shù)據(jù)時設(shè)置為null)刪除數(shù)據(jù)
mysql> delete from Customer where First_Name="hxn";更新數(shù)據(jù)
mysql> update Customer set First_Name="hxn" where Last_Name="lhk";添加列
mysql>alter table Customer add [column_name] [data_type];刪除列
mysql>alter table Customer drop [column_name] ;指定方式查詢
select * from Customer where City like "h%";(以h開頭)
select * from Customer where City like "%h"; (以h結(jié)尾)
select * from Customer where First_name="lhk" or Last_Name="hxn"; (or的使用)
select * from Customer where (First_Name > 100 or First_Name < 30) and City = null;(or與and連用)聯(lián)表查詢 join
select * from Customer2 join Customer where Customer.First_Name = Customer2.x;