标签:表数据 lse src where tables exe fun sql命令 指定
select owner,table_name from all_tables
grant execute on funtionname to username
SELECT tablespace_name,file_name,autoextensible FROM dba_data_files WHERE tablespace_name = ‘SCHEMA‘;
SELECT * FROM all_tab_columns WHERE table_name = ‘TABLENAME‘
SELECT table_name FROM user_tables
SELECT t.column_name, t.column_name FROM user_col_comments
SELECT column_name FROM user_col_comments WHERE table_name = ‘tablename‘;
SELECT t.table_name, f.comments FROM user_tables t INNER JOIN user_tab_comments f ON t.table_name = f.table_name;
SELECT t.table_name, f.comments FROM user_tables t INNER JOIN user_tab_comments f ON t.table_name = f.table_name WHERE t.table_name LIKE ‘BIZ_DICT%‘;
SELECT a.num_rows, a.table_name, b.comments FROM user_tables a, user_tab_comments b WHERE a.table_name = b.table_name ORDER BY table_name;
SELECT * FROM user_indexes
truncate table tablename
create table to_table as SELECT * FROM from_tablename WHERE columnname = ‘‘ --存放至新表 insert into to_table select * from table2 where --存放至已有表
SELECT * FROM tablename WHERE columnname = ‘&变量‘
DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )
merge into test_merge a using test b on(a.no=b.no) when matched then update set a.no2=b.no2 where a.no<>1 when not matched then insert values(b.no,b.no2) where a.no<>100
存储过程语法
创建过程
create or replace procedure NoParPro as //声明 ; begin // 执行 ; exception//存储过程异常 ; end;
create or replace procedure queryempname(sfindno emp.empno%type) //%type表示参数属性与表emp的empno字段一样 as sName emp.ename%type; sjob emp.job%type; begin .... exception .... end;
create or replace procedure runbyparmeters (isal in emp.sal%type, sname out varchar, sjob in out varchar) as icount number; begin select count(*) into icount from emp where sal>isal and job=sjob; if icount=1 then .... else .... end if; exception when too_many_rows then DBMS_OUTPUT.PUT_LINE(‘返回值多于1行‘); when others then DBMS_OUTPUT.PUT_LINE(‘在RUNBYPARMETERS过程中出错!‘); end;
存储过程调用
DECLARE realsal emp.sal%TYPE; realname VARCHAR(40); realjob VARCHAR(40); BEGIN / / 过程调用开始 realsal := 1100; realname := ‘‘; realjob := ‘CLERK‘; runbyparmeters(realsal, realname, realjob); --必须按顺序 / / runbyparmeters为存储过程 dbms_output.put_line(realname || ‘ ‘ ||realjob); END; / / 过程调用结束
declare realsal emp.sal%type; realname varchar(40); realjob varchar(40); begin //过程调用开始 realsal:=1100; realname:=‘‘; realjob:=‘CLERK‘; --指定值对应变量顺序可变 runbyparmeters(sname=>realname,isal=>realsal,sjob=>realjob); //runbyparmeters为存储过程 DBMS_OUTPUT.PUT_LINE(REALNAME||‘ ‘||REALJOB); END; //过程调用结束
SQL>exec proc_emp(‘参数1‘,‘参数2‘);//无返回值过程调用 SQL>var vsal number SQL> exec proc_emp (‘参数1‘,:vsal);// 有返回值过程调用 或者:call proc_emp (‘参数1‘,:vsal);// 有返回值过程调用
创建View
CREATE OR REPLACE VIEW V554211TJ01 AS SELECT T1.columnname1, t2.columnname2, ta.columnname2, t3.columnname2 FROM table1 T1 LEFT JOIN (SELECT ta.columnname1 columnname1 FROM table2 T2 WHERE T2.SDSRP5 = ‘KIT‘) TA ON TA.columnname1 = T1.columnname1, LEFT JOIN table3 T3 ON T3.columnname1=T1.columnname1 WITH READ ONLY
标签:表数据 lse src where tables exe fun sql命令 指定
原文地址:https://www.cnblogs.com/kevintam/p/11411700.html