Home » Other » Client Tools » Role of "/" and ";" in SQL file
Role of "/" and ";" in SQL file [message #290874] Tue, 01 January 2008 22:51 Go to next message
hidnana
Messages: 87
Registered: November 2007
Location: chennai
Member
Is there any difference between having "/" after every SQL statement in an SQL file and separating statements with a ";" having the "/" at the end of the SQL file.

Which is the correct method and convention to seperate the the statements ?


INSERT INTO TPD_TL_W_VE_UNIFCN_STATUS_RSN ( VE_UNIFCN_STATUS_RSN_ID,
VE_UNIFCN_STATUS_RSN_DESC ) VALUES ( 
13, 'GENERAL')
/
INSERT INTO TPD_TL_W_VE_UNIFCN_STATUS_RSN ( VE_UNIFCN_STATUS_RSN_ID,
VE_UNIFCN_STATUS_RSN_DESC ) VALUES ( 
14, 'PANL')
/  
COMMIT
/


B. 
INSERT INTO TPD_TL_W_VE_UNIFCN_STATUS_RSN ( VE_UNIFCN_STATUS_RSN_ID,
VE_UNIFCN_STATUS_RSN_DESC ) VALUES ( 
13, 'GENERAL');
INSERT INTO TPD_TL_W_VE_UNIFCN_STATUS_RSN ( VE_UNIFCN_STATUS_RSN_ID,
VE_UNIFCN_STATUS_RSN_DESC ) VALUES ( 
14, 'PANL');  
COMMIT;

/
Re: Role of "/" and ";" in SQL file [message #290880 is a reply to message #290874] Wed, 02 January 2008 00:24 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
Both will end and run a SQL command entered in SQL*Plus. The / will re-execute the last command in the buffer. So, in your second command, the ; would execute the commit once, then the / would re-execute the commit a second time.
Re: Role of "/" and ";" in SQL file [message #290882 is a reply to message #290874] Wed, 02 January 2008 00:31 Go to previous messageGo to next message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
At the SQL prompt, you can begin typing any SQL command. Upon hitting return (i.e., enter key) the SQL prompt will change to line number prompts. When you are finished typing a command, type / or RUN to execute the SQL command. Also, a semicolon at the end of the SQL command will execute the command immediately after hitting return. In addition to SQL commands, /, and RUN, other commands can be issued at the SQL prompt (a semicolon does not have to follow the nonSQL commands).
Re: Role of "/" and ";" in SQL file [message #290884 is a reply to message #290880] Wed, 02 January 2008 00:40 Go to previous messageGo to next message
hidnana
Messages: 87
Registered: November 2007
Location: chennai
Member
Can you tell me the difference when executing the sql from OS prompt instead of from SQL* plus like,
$ @script1.sql
Re: Role of "/" and ";" in SQL file [message #290892 is a reply to message #290884] Wed, 02 January 2008 00:57 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
In command prompt you need to execute the script using the following command:
Quote:

$ sqlplus <user/passwd@connect> @script1.sql
so that it will connect to SQL first.

By
Vamsi

[Updated on: Wed, 02 January 2008 00:57]

Report message to a moderator

Re: Role of "/" and ";" in SQL file [message #290928 is a reply to message #290892] Wed, 02 January 2008 03:38 Go to previous messageGo to next message
hidnana
Messages: 87
Registered: November 2007
Location: chennai
Member
I meant the difference in having separators as "/" and ";" in the sql file, while executing the sql file from the OS using @ command. Which is better method ? Separating the statements
by
a) /
OR
b) ; with / at the end ?

Re: Role of "/" and ";" in SQL file [message #290940 is a reply to message #290928] Wed, 02 January 2008 04:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL*PlusŪ User's Guide and Reference
Part II Using SQL*Plus
Chapter 4 SQL*Plus Basics
Section Running SQL Commands
Subsection Understanding SQL Command Syntax

Please read the doc BEFORE posting basic questions.

Regards
Michel
Re: Role of "/" and ";" in SQL file [message #291053 is a reply to message #290940] Wed, 02 January 2008 20:44 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
There is no real difference. Agree the method you prefer with your co-workers and stick to it.

Ross Leishman
Previous Topic: I can't get BREAK to work
Next Topic: How can i escape & in a query
Goto Forum:
  


Current Time: Fri Mar 29 03:23:16 CDT 2024