1024programmer Oracle Getting started with sqlplus

Getting started with sqlplus

the
1. Login:
1. sqlplus enters the user password according to the prompt, but there is no place to enter the database connection string, so you need to set ORACLE_SID in advance. the
2. sqlplus user/pass@db log in directly, the disadvantage is that the multi-user system may expose the password. the
3. sqlplus /nolog and then connect user/pass@db does not log in first, but starts sqlplus and then connects to the database. Compared with method 2, the password will not be exposed. the
Question:
When logging in, wrap user/pass@db in double quotes or single quotes, what is the difference between not wrapping it? the
Answer: The non-wrapping method is only supported after oracle10g.
www.2cto.com
2. Execution:
1. / A slash means that the statement in the execution buffer (just entered) must be on a single line, before oracle9i, there must be no space before /.
2. EXEC[UTE] stored procedure, execute the stored procedure (including function and package) in the database.
3. START|@ script file, execute the script file, if the script has no extension, automatically add .sql; if there is no path, it defaults to the current directory, or find it from the SQLPATH parameter.
4. @@ Script file, generally used in script files, means to execute the script file like @, but the current directory is the directory where the script where @@ is called.
the
3. Editing:
1. EDIT file name, start the editor, if there is no parameter, edit the statement in the buffer, and the buffer only retains the last executed statement.
The following is the command after entering the EDIT editor:
2. L lists the edited statement.
3. n refers to the nth line as the current line.
4. del deletes the current line.
5. c /old/new/ Replace old in the current line with new, / is a separator, it can also be!
6. n text Use text as the nth line.
7. I Insert a row after the current row.
8. a text Add characters at the end of the current line.
the
4. Error:
Execute the processing when an error occurs in the script. The default is to continue execution. If you need to terminate when an error occurs, add WHENEVER SQLERROR EXIT SQL.SQLCODE, or WHENEVER SQLERROR SQL.SQLCODE EXIT ROLLBACK.
the
5. Variables:
1. DEFINE x = “hello”; Use &x reference, which is only valid on the sqlplus side. When submitting sql or plsql, it will be submitted after the value is replaced. www.2cto.com
2. VARIABLE x varchar2(10); Define a plsql binding variable and pass it to the database server as a parameter.
the
6. Common formats:
set serverouput on: display the output of plsql
set echo on : Display the executed statement
set feedback on : display the number of records of the query result
set heading on : Display the column header of the data
set linesize 80 : Up to 80 characters per line
set pagesize 24 : Up to 24 lines per page
set timing on : display execution time
set autotrace on : display execution plan
set sqlblankline on : Allow blank lines in script execution
set column dept format a15 heading 'department' : Set the column dept to display a width of 15 characters, and the column header is department
set define off : Do not check special characters in the script, such as the & symbol, the default is the input parameter flag.
the
the
Author hulubo

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/getting-started-with-sqlplus/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索