Oracle 必会

来源:互联网 发布:万宝路黑冰爆珠淘宝 编辑:程序博客网 时间:2024/06/05 15:51
Oracle 基础整理 
1.创建表
create table  testt(
t_date date,
t_age number,
t_name varchar2(100)
);
2.查询所有数据
select count(*) from testt;
select * from  testt;--一遍不要使用* 号  如果表中数据量大的话  会引爆数据库  建议先使用  count(*)代替 看数据不多可以使用*
3.查询指定一个字段值
select t_age from testt;
select to_char(t_date,'yyyy-mm-dd')  from  testt;
4.查询指定多个字段值
select t_age,t_name,t_date from testt;
5.给所有字段添加数据
insert into testt values(sysdate,6.01,'littlewhite');
insert into testt values(to_date('2017-06-19','yyyy-mm-dd'),6.01,'littlewhite');
6.指定字段添加数据
insert into testt (t_age) values(3.01); 
7.删除表  
drop table testt;
8.恢复表
flashback table testt to before drop 
9.删除指定数据
delete from testt where t_age = 3.01;


1.修改表名字
alter table testt  rename to littlewhite;
2.添加表字段 
alter table testt add t_add varchar2(80);
3.指定表字段修改名字
alter table testt rename column t_add to t_modify
4.删除表字段
alter table testt drop column t_modify;
原创粉丝点击