一些简单的SQL语句
1.创建数据库:create database database-name
2.删除数据库:delete database database-name
3.选择:select * from table where ...
4.插入:insert into table(field1,field2) values(value1,value2)
5.更新:update table set field1=value1 where ...
6.删除:delete from table where 范围
7.查找:select * from table where field1 like '%value1%'
8.排序: select * from table where order by field1,field2 [desc]
9.总数:select count as totalcount from table
10.求和:select sum(field1) as sumvalue from table
11.平均:select avg(field1) as avgvalue from table
12.最大:select max(field1) as maxvalue from table
13.最小:select min(field1) as minvalue from table
14.备份数据库:backup database database-name to disk
15.创建新表:create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
16.增加一列:Alter table tabname add column col type
17.添加主键:Alter table tabname add primary key(col)
18.删除主键:Alter table tabname drop primary key(col)
19.创建视图:create view viewname as select statement
20.删除视图:drop view viewname