表的定义和修改:
Oracle的数据类型,函数,事物及失误权限,表的约束
(表级定义,列级定义)
create table users(
ud number(4,0),
id number(3,-2),
nam char(32),
addrss varchar2(32),
birthday Date
);
rename users to users_;
rename users_ to users;
alter table users add(
add_col nvarchar2(12)
);
alter table users drop column add_col;
alter table users modify (
namvarchar2(64)
);
desc users;
drop table users;
//插入数据
insert intousers(ud,id,nam,addrss,birthday) values (1,156,'aaaa','aaa','12-9月-2012');
insert into users values(2,126,'bbbb','ccccc','11-9月-2012');
insert into users values(2,126,'bbbb','','11-9月-2012');
//查询数据
select * from users;
SELECT nam ,dump(nam) FROM users whereud=1;
//更新数据
update users set nam='Andy' where ud=1;
update users set addrss='bbb' where ud=2;
update users set id=300;
update users set addrss='op' where addrssis null;
//删除数据
delete users where ud=3;
序列:
/创建序列
create sequence seq
start with 1
increment by 1
minvalue 1
maxvalue 12000
cycle
nocache;
/使用seq
create table demo1(
idnumber primary key,
namevarchar2(32)
);
insert into demo1 values(seq.nextval,'andy');
select * from demo1;