How does the SQL PLUS command work normally?

Source: Internet
Author: User

The following content mainly introduces the actual use of the SQL plus command. If you are interested in the actual use of the SQL PLUS command, the following articles will provide you with relevant knowledge. The following is a detailed description of the article.

1. Execute an SQL script file

 
 
  1. SQL>start file_name   
  2. SQL>@ file_name  

We can save multiple SQL statements in a text file, so that when you want to execute all the SQL statements in this file, use any of the following SQL PLUS commands, this is similar to batch processing in dos.

2. Edit the current input.

 
 
  1. SQL>edit  

3. Run the last SQL statement again.

 
 
  1. SQL>/  

4. output the displayed content to the specified file.

 
 
  1. SQL> SPOOL file_name  

All content on the screen is included in this file, including the SQL statement you entered.

5. Disable spool output

 
 
  1. SQL> SPOOL OFF  

The output content is displayed in the output file only when spool output is disabled.

6. display the structure of a table

 
 
  1. SQL> desc table_name  

7. COL command:

It mainly formats the display of columns.

The SQL PLUS command has the following options:

 
 
  1. COL[UMN] [{ column|expr} [ option ...]]  

The Option can be the following clause:

 
 
  1. ALI[AS] alias   
  2. CLE[AR]   
  3. FOLD_A[FTER]   
  4. FOLD_B[EFORE]   
  5. FOR[MAT] format   
  6. HEA[DING] text   
  7. JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]}   
  8. LIKE { expr|alias}   
  9. NEWL[INE]   
  10. NEW_V[ALUE] variable   
  11. NOPRI[NT]|PRI[NT]   
  12. NUL[L] text   
  13. OLD_V[ALUE] variable   
  14. ON|OFF   
  15. WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]  

1). Change the default Column Title

 
 
  1. COLUMN column_name HEADING column_heading   
  2. For example:   
  3. Sql>select * from dept;   
  4. DEPTNO DNAME LOC   
  5. 10 ACCOUNTING NEW YORK   
  6. sql>col LOC heading location   
  7. sql>select * from dept;   
  8. DEPTNO DNAME location   
  9. 10 ACCOUNTING NEW YORK  

2) Change the column NAME to the new column NAME "employee name" and put the new column NAME on two rows:

 
 
  1. Sql>select * from emp   
  2. Department name Salary   
  3. 10 aaa 11   
  4. SQL> COLUMN ENAME HEADING ’Employee|Name’   
  5. Sql>select * from emp   
  6. Employee   
  7. Department name Salary   
  8. 10 aaa 11   
  9. note: the col heading turn into two lines from one line.  

3). Change the display length of the column:

 
 
  1. FOR[MAT] format   
  2. Sql>select empno,ename,job from emp;   
  3. EMPNO ENAME JOB   
  4. 7369 SMITH CLERK   
  5. 7499 ALLEN SALESMAN   
  6. 7521 WARD SALESMAN   
  7. Sql> col ename format a40   
  8. EMPNO ENAME JOB   
  9. 7369 SMITH CLERK   
  10. 7499 ALLEN SALESMAN   
  11. 7521 WARD SALESMAN  

The above content is an introduction to the use of SQL PLUS commands.

Article by: http://www.programbbs.com/doc/class10-3.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.