SQL(Struct Query Language)结构化查询语言是关系数据库管理系统的标准语言。Create,Select,Insert,Update,Delete,Drop table。
1、Select
select [column1, column2,etc] from tablename
[where condition];
例如:
select select firstname, lastname, city
from employee
where firstname LIKE E%';
select * from employee
where firstname = 'Ma';
2、Create
create table tablename
(column1 data type,
column2 data type,
column3 data type);
create table tablename
(column1 data type [constraint],
column2 data type [constraint],
column3 data type [constraint]);
例如:
create table employee
(firstname varchar(15),
lastname varchar(20),
age number(3),
address varchar(30),
city varchar(20));
3、Insert
insert into tablename
(first_column,...last_column)
values (first_value,...last_value);
例如:
insert into employee
(firstname, lastname, age, address, city)
values ('Li', 'Ming', '45', 'No.77 Changan Road', 'Beijing');
4、Update
update tablename
set columnname = newvalue [, nextcolumn = newvalue2...]
where columnname OPERATOR value [and or column OPERATOR value];
例如:
update employee
set age = age+1
where first_name='Mary'and last_name='Williams';
5、Delete
delete from tablename
where columnname OPERATOR value [and or column OPERATOR value];
例如:
delete from employee
where lastname = May;
6、Drop table
drop table tablename;
例如:
drop table employee;
SELECT…FROM的详细用法必须
DISTINCT
SUM
AVG
COUNT
GROUP BY
HAVING
ALIAS