oracle常用sql

-- 查看建表sql
select dbms_metadata.get_ddl('TABLE',upper('guQuotationMain')) from dual; 

select dbms_metadata.get_ddl('TABLE',upper('gguser')) from dual; 


-- 查看字段注释
SELECT 
    B.COLUMN_NAME,
    A .DATA_TYPE || '(' || A .CHAR_LENGTH || ')',
    B.COMMENTS,
    A .COLUMN_ID
FROM
    USER_TAB_COLUMNS A
INNER JOIN USER_COL_COMMENTS B ON A .TABLE_NAME = B.TABLE_NAME
AND A .COLUMN_NAME = B.COLUMN_NAME
WHERE
    A .TABLE_NAME = UPPER ('GuPolicyRelatedParty')
ORDER BY
    COLUMN_ID;

SELECT 
    B.COLUMN_NAME,
    A .DATA_TYPE || '(' || A .CHAR_LENGTH || ')',
    B.COMMENTS,
    A .COLUMN_ID
FROM
    USER_TAB_COLUMNS A
INNER JOIN USER_COL_COMMENTS B ON A .TABLE_NAME = B.TABLE_NAME
AND A .COLUMN_NAME = B.COLUMN_NAME
WHERE
    A .TABLE_NAME = UPPER ('GGSERVICECALLHISTORY')
ORDER BY
    COLUMN_ID;

-- 查看表是否有某个字段
-- 查看字段注释
SELECT DISTINCT
    B.COLUMN_NAME,
    A .DATA_TYPE || '(' || A .CHAR_LENGTH || ')' data_type,
    B.COMMENTS,
    A .COLUMN_ID
FROM
    USER_TAB_COLUMNS A
INNER JOIN USER_COL_COMMENTS B ON A .TABLE_NAME = B.TABLE_NAME
AND A .COLUMN_NAME = B.COLUMN_NAME
WHERE
    A .TABLE_NAME = UPPER ('gguser') and B.COLUMN_NAME=upper('USERCODE')

--  查询表注释
SELECT t1.TABLE_NAME,t2.comments 
FROM USER_TABLES t1 left join user_tab_comments t2 on (t1.TABLE_NAME=t2.TABLE_NAME and t2.TABLE_TYPE='TABLE')
where t1.TABLE_NAME=upper('guQuotationmain')


-- 查询表索引
select t1.index_name, t1.column_name,t2.uniqueness
from  user_ind_columns t1 LEFT JOIN user_indexes t2 on t1.index_name=t2.index_name
WHERE t1.table_name=upper('guQuotationMain');

--查看存储过程
select DISTINCT(name) from user_source where type='PROCEDURE';

select rownum , text from user_source where type='PROCEDURE' and name='GET_B2B_QUOTATIONINFO' 
order by line;

-- 创建存储过程
create or replace PROCEDURE GET_B2B_QUOTATIONINFO
IS
BEGIN
    select 1 from dual;
end GET_B2B_QUOTATIONINFO;


-- 删除存储过程
drop procedure GET_B2B_QUOTATIONINFO;

-- 调用存储过程
BEGIN
    GET_B2B_QUOTATIONINFO()
end GET_B2B_QUOTATIONINFO;
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值