当前位置:Gxlcms > 数据库问题 > 五、oracle 表的管理

五、oracle 表的管理

时间:2021-07-01 10:21:17 帮助过:2人阅读


--错误写法:select * from student where birthday = null;
--正确写法:select * from student where birthday is null;
--如果要查询birthday不为null,则应该这样写:
select * from student where birthday is not null;

         

--修改数据
--修改一个字段
update student set sex = ‘女‘ where xh = ‘a001‘;
--修改多个字段
update student set sex = ‘男‘, birthday = ‘1984-04-01‘ where xh = ‘a001‘;
--修改含有null值的数据
不要用 = null 而是用 is null;
select * from student where birthday is null;

        

--删除数据
delete from student; --删除所有记录,表结构还在,写日志,可以恢复的,速度慢。
--delete的数据可以恢复。
savepoint a; --创建保存点
delete from student;
rollback to a; --恢复到保存点
一个有经验的dba,在确保完成无误的情况下要定期创建还原点。

drop table student; --删除表的结构和数据;
delete from student where xh = ‘a001‘; --删除一条记录;
truncate table student; --删除表中的所有记录,表结构还在,不写日志,无法找回删除的记录,速度快。

五、oracle 表的管理

标签:

人气教程排行