命令:
1. show databases呛凶; //查看數(shù)據(jù)庫
2.use databaseName;//使用數(shù)據(jù)庫
3.drop database databaseName;刪除數(shù)據(jù)庫
4.show tables混聊;//展示數(shù)據(jù)庫中有多少表
5.drop table tableName;//刪除表
6.create database databaseName;//創(chuàng)建數(shù)據(jù)庫
7.create table tableName(name 數(shù)據(jù)類型 [主鍵] [約束],ID 數(shù)據(jù)類型 [主鍵] [約束], ...);//創(chuàng)建表
8.insert into tableName(name , ID)values('name','num');//插入數(shù)據(jù)
9.insert into tableName(name , ID)values('name1','num1')茸塞, ('name2','num2'), ...? //插入數(shù)據(jù)
10.update tableName set name = 'xx' where ID = xxxx ;//將ID 為xxxx所在行中的 name的數(shù)據(jù)改為xx
11.delete from tableName Where ID = 'num1';//刪除ID = 'num1'所在的行
12.drop table tableName ;//刪除表中所有數(shù)據(jù)
13.select * from tableName;//查看表中內(nèi)容;
14.select?distinct?表屬性1?from tableName;//從tableName中的表屬性1行中消除重復(fù)數(shù)據(jù)查剖;
15.SELECT?* FROM tableName WHERE 條件;//從tableName表中查詢滿足條件的數(shù)據(jù)钾虐;
16.SELECT?* FROM tableName WHERE?列的名字 BETWEEN?最小值 AND 最大值;
17.SELECT * FROM?tableName WHERE?某列的名字 LIKE '%x%';//選出某列中包含x的數(shù)據(jù)
18.SELECT * FROM?tableName ORDER BY columnName ASC/DESC;//排序 升序/降序
19.SELECT * FROM tableName WHERE??條件 LIMIT pagecount, pagesize; //將滿足條件的數(shù)據(jù)分頁
20.alter table?table_Name drop?column def ; 將表中,列名abc的列刪除
21.alter table t1 add column?列名 varchar(20) not null first; 插入到第一行笋庄;
22.select 表1列名1, 表1列名2,... ,表2列名1,表2列名2,...?FROM 表1,表2 where 表1.列名=表2.列名";? 多表查詢 (藍色部分相當于*)
約束和主鍵在創(chuàng)建表的時候?qū)懭?/p>