自学oralce,看到啥写点啥

1.查询语句

select * from TF_B_TERM_PREPMG_LOG;


select * from TD_M_TERM_PRICE;


select * from TF_B_CEN_TERM_MANAGER_LOG,TF_B_CEN_TERM_MANAGER_DETAIL;    //两张表一起查


select * from TF_B_CEN_TERM_MANAGER_DETAIL;


select * from TF_B_CEN_TERM_MANAGER_LOG;


select log_id*(1+0.1)newLog_id from  TF_B_CEN_TERM_MANAGER_LOG;      //将log_id上调10%展示出来,通过newlog_id展示出来


select distinct log_id from TF_B_CEN_TERM_MANAGER_LOG;              //distinct :过滤掉关键字相同的数据


select * from TF_B_CEN_TERM_MANAGER_LOG where log_id is null;            //查询条件是某个字段为null时,语句
select * from TF_B_CEN_TERM_MANAGER_LOG where log_id is not null;


select * from TF_B_CEN_TERM_MANAGER_LOG where log_id > 300 order by log_id ;     //order by 默认的是升序排列
select * from TF_B_CEN_TERM_MANAGER_LOG where log_id > 300 order by log_id desc;    //order by 默认的是升序排列,如果需要降序排列,在后面加上desc
select * from TF_B_CEN_TERM_MANAGER_LOG where log_id > 300 order by log_id,res_trade_id desc ;      //order by 可以带上多个参数排列,原则是排完第一个,在排序第二个


//常用的函数
select count(*) from TF_B_CEN_TERM_MANAGER_LOG;        //统计表中所有的记录数 count(*)
select avg(log_id) from TF_B_CEN_TERM_MANAGER_LOG;    //统计表中字段的平均数 avg(keyword) 
select min(log_id) from TF_B_CEN_TERM_MANAGER_LOG;    //统计表中某个字段的最小值
select max(log_id) from TF_B_CEN_TERM_MANAGER_LOG;     //统计表中某个字段的最大值
select sum(log_id) from TF_B_CEN_TERM_MANAGER_LOG;     //统计表中某个字段的和


select avg(log_id) from TF_B_CEN_TERM_MANAGER_LOG group by log_id;          //关联所有的logid相同的记录,通常和上面的几个函数一起使用
select avg(log_id) from TF_B_CEN_TERM_MANAGER_LOG group by log_id having avg(log_id) > -1;     //having 语句通常和 group by 一起使用

 

2.

 

create index index_name on table_name (cloumn_names);

drop table table_name;    //删除表,表中的数据和索引等一并删除掉,oracle中的,以此表简历的视图,不会随着删除表而删除,但是使用的时候会报错

drop view view_name;

drop index index_name;

                                                   //语句是没有问题,但是问题如下:
                                                   //由于test 表巨大 估计有1亿  在增加 字段时 就不那么容易了,因为default 会锁表
alter table test add nf_quota integer default 0;   //现在想问一下高手,是否可以对已有的记录 不指定缺省值,
                                                   //对新增的记录指定缺省值,这样的语句该如何写?
                                                   //这样的语句是否可以在巨型表上执行?
                                                   
                                                   
alter table test drop column_name;  //如果表中只有一个字段,直接删除表                                           
                                                   

alter table test modify column_name long;
 
alter table table_name rename to new_table_name;

alter table table_name rename column_name to new_column_name;


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值