oralce的约束:
1.非空约束
2.主键约束
3.唯一约束
4.外键约束
5.检查约束
约束的作用:
1.定义规则
2.确保数据的完整性
1.非空约束
2.主键约束
3.唯一约束
4.外键约束
5.检查约束
约束的作用:
1.定义规则
2.确保数据的完整性
2018-05-16
--无条件删除
delete from userinfo
--有条件删除
delete from userinfo where username = 'yyy'
delete from userinfo
--有条件删除
delete from userinfo where username = 'yyy'
2018-05-16
--无条件全部更新
update userinfo set userpwd = '111111'
update userinfo set userpwd ='111', email = '111@126.com'
--限制更新
update userinfo set userpwd = '123456' where username ='xxx'
update userinfo set userpwd = '111111'
update userinfo set userpwd ='111', email = '111@126.com'
--限制更新
update userinfo set userpwd = '123456' where username ='xxx'
2018-05-16
--创建表时复制(全部字段)
create table userinfo_new as select * from userinfo
--复制部分字段
create table userinfo_new1 as select id,username from userinfo
--在添加时复制全部数据
insert into userinfo_new select * from userinfo;
-- 在添加时复制部分数据
insert into userinfo_new (id,username) select id,username from userinfo
create table userinfo_new as select * from userinfo
--复制部分字段
create table userinfo_new1 as select id,username from userinfo
--在添加时复制全部数据
insert into userinfo_new select * from userinfo;
-- 在添加时复制部分数据
insert into userinfo_new (id,username) select id,username from userinfo
2018-05-16
--修改字段的名字
alter table userinfo rename column email to new_email
--表改名
rename userinfo to new_userinfo
select * from new_userinfo
alter table userinfo rename column email to new_email
--表改名
rename userinfo to new_userinfo
select * from new_userinfo
2018-05-15
--更改字段的数据类型(更改长度/类型)
alter table userinfo modify remarks varchar2(400);
alter table userinfo modify userpwd number(6,0);
--删除字段
alter table userinfo drop column remarks;
alter table userinfo modify remarks varchar2(400);
alter table userinfo modify userpwd number(6,0);
--删除字段
alter table userinfo drop column remarks;
2018-05-15
--创建表
create table userinfo
(
id number (6,0),
username varchar2(20),
userpwd varchar2(20),
email varchar2(30),
regdate date
);
--查询
select * from userinfo;
create table userinfo
(
id number (6,0),
username varchar2(20),
userpwd varchar2(20),
email varchar2(30),
regdate date
);
--查询
select * from userinfo;
2018-05-15
不建议直接删除表空间,
删除后在创建test1file.dbf时报错,提示文件已存在,
删除表空间是需要在后面加 including contents
删除后在创建test1file.dbf时报错,提示文件已存在,
删除表空间是需要在后面加 including contents
2018-05-15