您好,欢迎访问一九零五行业门户网

oracle中PLSQL语句

1.set autot off 禁止使用autotrace命令 set autot on 这个命令包括exp 和 stat(执行语句、生成explain plan、生成统计信息) set autot trace 不执行sql语句,但(生成explain plan、生成统计信息) set autot trace exp stat 与上句同 set autot trace st
1.set  autot off 禁止使用autotrace命令
set autot on 这个命令包括exp 和 stat(执行语句、生成explain plan、生成统计信息)
set autot trace 不执行sql语句,但(生成explain plan、生成统计信息)
set autot trace exp stat 与上句同
set autot trace stat 不执行sql语句,但(生成explain plan)
2.序列sequence_name.nextval 求出接下来的最高值
sequence_name.currval 最近一次调用nextval时返回的值
3. 创建以10开始的序列create sequence my_sequence start with 10;
查询序列中接下来的最高值 select my_sequence.nextval from dual;
4. create sequence student_seq;
create table student(n varchar(10));
insert into student values('a'||lpad(student_seq.nextval,9,'0'));
select * from student;
n
----------
a000000002
5.  --execute immediate 'set constraints all deferred';
create or replace procedure p is
begin
 insert into student values ('a000000004');
 insert into student values('a000000005');
 insert into student values ('a000000006');
 commit;
 end p;
6.select * from tab;查看表空间中所有表
7.select * from v$tablespace;查看数据库中的所有表空间
8.
set serveroutput on
即打开oracle自带的输出方法dbms_output。在执行set serveroutput on以后,
使用dbms_output方法可以输出信息,
例如:dbms_output.put_line('this is mine');
1)创建存储过程
sql> set serveroutput on
sql> create or replace procedure hello is
  2  begin
  3  dbms_output.put_line('hello world');
  4  end;
  5  /
过程已创建。
2)执行存储过程
sql> execute hello (或者exec hello)
hello world
pl/sql 过程已成功完成。
3)删除存储过程
sql> drop procedure hello
  2  ;
过程已删除。
9.sql*plus 缓冲区默认大小是20,000字符,最大可以增加到1,000,000字符
sql> execute dbms_output.enable(1000000);
pl/sql 过程已成功完成。
将缓冲区的内容保存到文件中
sql> create or replace procedure hello is
  2  begin
  3      dbms_output.put_line('hello world,zhang da wang,heihei');
  4  end;
过程已创建。
sql> save hello
已创建 file hello.sql --文件的路径为:f:\oracle\product\10.2.0\db_1\bin
sql> @hello.sql
过程已创建。
sql> exec hello
hello world,zhang da wang,heihei
pl/sql 过程已成功完成。
10.赋值操作符“:=”
if条件判断表达式if(a=b)
字符串连接操作符“||”
变量声明区位于is和begin之间
其它类似信息

推荐信息