数据库基本语言
1、说明:创建数据库create database “name”
2、说明:删除数据库drop database dbname
3、说明:创建新表create table “name”
4、说明:删除新表drop table “name”
5、说明:添加主键 Alter table “name” add primary key(col)
6、说明:删除主键: Alter table “name” drop primary key(col)
8、说明:创建索引 create [unique] index indexname on tablename
9、说明:删除索引drop index indexname(注:索引是不可更改的,想更改必须删除重新建。)
10、说明:创建视图create view “name”
11、说明:删除视图drop view “name”
12、说明:几个简单的基本的sql语句:
选择:select * from tablel where 范围
插入:insert into tablel(fieldl, field2) values(valuel, value2)
删除:delete from tablel where 范围
更新:update tablel set field1=value where 范围
查找:select * from tablel where field like ‘%value1%’
排序:select * from tablel order by field1,field2 [desc]
总数:select count as totalcount from table
求和:select sum(field) as suvalue fron table
平均:select avg(field) as avgvalue from table
最大: select max(field) as from table
最小:select min(field) as minvalue from table