how to change the delimiter in sqlplus in oracle 11g

送分小仙女□ 提交于 2019-12-10 22:11:50

问题


I want to change the delimiter:

Can someone help me to change the delimiter in sqlplus in Oracle 11g

CREATE OR REPLACE TRIGGER test_trigger 
BEFORE INSERT ON test 
REFERENCING NEW AS NEW FOR EACH ROW 
BEGIN 
SELECT test_sequence.nextval INTO :NEW.ID FROM dual; 
END; 
/ 

this is the trigger I want to create. but after Select statement it stops because of ; is there. that is why I want to change the delimiter. I hope everyone gets the idea on this now..


回答1:


There is nothing wrong with the syntax of your trigger. I can run it in my (vanilla) SQL*Plus environment:

SQL> CREATE OR REPLACE TRIGGER test_trigger
  2  BEFORE INSERT ON test
  3  REFERENCING NEW AS NEW FOR EACH ROW
  4  BEGIN
  5  SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
  6  END;
  7  /

Trigger created.

SQL>

And lo! the trigger works:

SQL> insert into test (col1) values ('Simples!')
  2  /

1 row created.

SQL> select * from test
  2  /

        ID COL1
---------- ------------
         1 Simples!

SQL>

All I can think is that you have some blank lines in the code which you are typing. If this is the situation you can override the default behaviour with this SQL*Plus command:

SQL>  set sqlblanklines on



回答2:


Is this you are looking for

select q'#Oracle's quote operator#' from dual;

Q'#ORACLE'SQUOTEOPERATO
-----------------------
Oracle's quote operator

Edit 1:

CMDS[EP] {;|c|OFF|ON}

   Change or enable command separator - default is a semicolon (;)



回答3:


If you're using SQLPlus and not some other tool I'm not sure what the root issue is, but here's the answer to your workaround question:
To change the command delimiter from the default value of ; use

SQL> set cmdsep /
SQL> show cmdsep
cmdsep "/" (hex 2f)

To restore the default value after you've created your trigger:

SQL> set cmds off
SQL> show cmds
cmdsep OFF



回答4:


SQL> set sqlt /

to set sql terminator to '/'

SQL> show sqlt

to check current sqlterminator



来源:https://stackoverflow.com/questions/3005349/how-to-change-the-delimiter-in-sqlplus-in-oracle-11g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!