Oracle note (2) SQLPlus command

Source: Internet
Author: User


Oracle note (2) the SQLPlus command mainly uses the command line method for Oracle database operations, and all commands are completed using sqlplus. There are two forms of sqlplus. One is dos-style sqlplus: sqlplus.exe; the other is windows-style sqlplus: sqlplusw.exe; sqlplusw commands are mainly used in Oracle 10 Gb, because it can adjust some display data. Www.2cto.com



The default available database instance is found. Example: Enter the query command SELECT * FROM emp;

At this time, the data can be normally displayed, but there will still be a data line problem, because this is the default data size of each line, and now you can adjust it using two commands: SET the length of records displayed per line: set linesize 300; SET the length of records displayed per page: set pagesize 30;

These two commands will be called the formatting command in the future, but the setting of these formatting commands under sqlplus is not very obvious. Although sqlplusw is easier to display, it is not very convenient to edit the command. For example, if the command is wrong during normal operations, you must use the direction key to move it to the wrong position for modification, however, in sqlplusw, the arrow keys can only control the movement of the screen, so this command is not suitable for editing at all. Therefore, the ed and @ commands are provided in sqlplusw to call and execute notepad; use ed to call the Notepad program: ed;
At this time, the user will be prompted that ". SQL file, ask whether to create, select "yes", but after using ed to open notepad, The sqlplusw window in Oracle will enter the blocking status and cannot be used. Run the @ program: @ a; program file to save the program code.
To read the file on the hard disk, you must enter the complete path @ D: \ demo.txt. If the file is suffixed with "*. SQL, you do not need to enter the file suffix (demo. SQL), enter @ d: \ demo, or enter @ d: demo directly. Www.2cto.com has many users in a database (currently four users are known). Each user has multiple data tables of their own, so to view all data tables, you can use the following command:
SELECT * FROM tab; if you want to know the current logon USER, you can run the: show user; command. In addition, you can directly switch user logon in sqlplusw by using the following syntax: CONN user name/password [as sysdba]; Use sys User Logon: CONN sys/change_on_install as sysdba; however, once the sys connection is used, the emp table data cannot be directly queried.
Each table has its users. Therefore, the full name of a table is "user name. table name or schema name. table Name ", so different users should add the user name, that is, the current access name: SELECT * FROM scott. emp; once the super administrator is used to log on, you can use commands to manually control the opening and closing of database instances; shut down database instances: shutdown immediate; Once disabled, you cannot directly connect to the sqlplusw command, in this case, you can use "/nolog" to log on, and then use the Administrator to log on. www.2cto.com SQL> conn sys/sys as sysdba; connected. SQL> shutdown immediate; the database has been closed. The database has been detached. The ORACLE routine has been disabled. SQL>
Start database instance: STARTUP;

In addition, the sqlplusw command window can also call the local operation command and use "host" as the prefix. Host copy d: \ demo. SQL d: \ hello.txt
The above commands must be mastered and will be used in the future.
 

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.