二,SQL语句

数据类型定义:

lchar(n). Fixed length character string, with user-specified length  n.

lvarchar(n). Variable lengthcharacter strings, with user-specified maximum length n.

l int. Integer (a finite(有限的) subset of the integers that is  machine-dependent).

l smallint. Small integer (a machine-dependent subset of the  integer domain type).

l numeric(p,d). Fixed point number, with user-specified precision of pdigits, with d digits to the right of decimal point. 

l real, double precision.  Floating point and double-precision  floating point numbers, with machine-dependent precision.

l float(n). Floating point number, with user-specified precision  of at least n digits.

l date, time, timestamp, interval

l Each type mayinclude a special value called the null value

 

建立table

createtable department

  (dept_name varchar (20),

 building varchar (15),

 budget numeric (12,2),

 primary key (dept_name)); --设置主码

 

基本格式:

create table r

 (A1 D1,

A2 D2,

...,

An Dn,

(integrity-constraint1),...,

(integrity-constraintk));

 

删除table

drop table table_name

Deleteall information in the table

 

修改table

向某个表中增添一个属性

altertable table_name

add A D

(A is thename of  the attribute , and the D is thetype of A) 

 

向某个表中删除一条属性:

altertable table_name

drop A

(A is anattribute name.)

 

向表中插入数据:

insertinto table_name

values(D1, D2, D3, D4, D5...);

 

清空一个表:

deletefrom table_name

表中所有元祖都被删除,但是表依然存在,也就是说此时这个表是个空表。

 

更新操作:

updateinstructor

setsalary = salary * 5;

将工资增加到原来的五倍。

 

 

你可能感兴趣的:(二,SQL语句)