您的位置:首页 > 数据库 > Oracle

oracle 基础知识查询

2017-08-29 16:44 537 查看
1.提高执行效率

/*+INDEX (client_id)*/
/*+ index(b)*/ --强制B表索引
/*+leading(linshib) parallel(order,10) full(order)*/   --临时表,生产表,生产表
/*+leading(v) index(v,IDX_VEH_VEHICLE_NO)*/


2.kill 会话 语句

username  SID    SERIAL
exec prc_kill_session('DBMONOPR02','5431','1');
command window 执行


3.查看ORACLE版本信息

select * from v$version;


4.授权

Grant all on table_name to public;

Grant all on table_name to user;


授权的用户表前加授权的用户名

5.给表或列添加、查询、删除 注释

--给表添加注释
COMMENT ON TABLE 表名 IS '要添加的注释';
comment on table hc_0829_1 is '测试表';

--给列添加注释
COMMENT ON COLUMN 表名.列名 IS '要添加的注释'
comment on column hc_0829_1.premium is '保费'

--查询表的注释
select * from user_tab_comments a where a.table_name = 'HC_0829_1';

--查询列的注释
select * from user_col_comments a where a.table_name = 'HC_0829_1';

--删除注释,即赋空值
comment on table hc_0829_1 is '';
comment on column hc_0829_1.premium is ''


6.建索引

create index IDX_policyno on hc_0829_1(字段) parallel 20;   --索引   表  字段  并发


7.删除表的某列

alter table hc_0829_1 drop (字段);


8.增加表的某列

alter table hc_0829_1 add columnName varchar(30)


9.更改表中列的长度

alter table hc_0829_1 modify  字段 varchar2(100);


车龄计算

TRUNC(MONTHS_BETWEEN(SYSDATE, b.first_register_date) / 12)


11.年龄限制

where extract(year from sysdate) - extract(year from b.cust_dob) >= 25
and extract(year from sysdate) - extract(year from b.cust_dob) <= 55
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: