查看數(shù)據(jù)庫:
show databases
選擇數(shù)據(jù)庫
USE database_name
表定義信息
?describe table_name
插入數(shù)據(jù):
insert into table_name (filed_1 ... field_n) ? ?values (value_1 ... value_n)
eg: insert into person_no (NAME,AGE) ?values ('Tom',10)?
更新數(shù)據(jù):
update table_name ? set field_1 = value_1 ... filed_n = value_n where condition
eg: update person_no set AGE = ?20 where NAME = 'Tom'
查詢數(shù)據(jù):
select * from table_name where condition
模糊查詢:前匹配滓走、后匹配和任意位置匹配
select * from table_name where field1 like ' %value1%' ?/ like 'value2% ?/ ?like '%value3'
注:該查詢語句效率較低
排序查詢:升序和降序
select field_1, field_n? from table_name where condition order by field_name [ASC|DESC]
去重查詢:
select distinct field_1, field_n from table_name
查詢總數(shù):
select count(*)/count(0) * from table_name
查詢前100條數(shù)據(jù):
select top 100 * from table_name
刪除數(shù)據(jù):
delete from table_name where condition