Home  >  Article  >  Database  >  Usage of sqlplus command

Usage of sqlplus command

小老鼠
小老鼠Original
2024-05-07 17:12:19856browse

Abstract: SQLPlus is an Oracle database interactive tool used to connect to the database and execute SQL statements. It can be started from the command line, and the command structure includes SQL statements, semicolons, and newlines. Basic command: CONNECT: connect to the database. DISCONNECT: Disconnect. SELECT: Query data. UPDATE: Update data. INSERT: Insert data. DELETE: delete data.

Usage of sqlplus command

SQLPlus command usage

SQLPlus is an interactive tool provided by the Oracle database management system for connecting to the database and execute the SQL statement.

Start SQLPlus

Open a command line or terminal and type the following command:

<code>sqlplus username/password[@database]</code>
  • username: database user Name
  • password: Database password
  • @database: Optional parameter, specify the database instance to be connected

SQLPlus command structure

SQLPlus command generally consists of the following parts:

  • SQL statement: used to execute queries, updates, and inserts and delete operations.
  • Semicolon (;): Terminates the SQL statement.
  • Line break: Execute SQL statement.

Basic commands

  • CONNECT: Connect to the database.
  • DISCONNECT: Disconnect from the database.
  • SELECT: Query data.
  • UPDATE: Update data.
  • INSERT: Insert data.
  • DELETE: Delete data.

Other common commands

  • SHOW USER: Display the current user.
  • DESC table_name: Describes the table structure.
  • SET LINESIZE value: Set the maximum width of the output line.
  • SET PAGESIZE value: Set the maximum number of lines in the output page.
  • SPOOL file.txt: Redirect output to a file.
  • EXIT: Exit SQLPlus.

Example

The following example shows how to perform basic operations using SQLPlus:

  • Connect to Database

    <code>SQL> CONNECT user1/password@orcl</code>
  • Query data

    <code>SQL> SELECT * FROM employees;</code>
  • Update data

    <code>SQL> UPDATE employees SET salary = salary * 1.10
    WHERE department_id = 10;</code>
  • Disconnect from the database

    <code>SQL> DISCONNECT</code>

Note:

  • SQLPlus commands are not case sensitive.
  • SQL statements must end with a semicolon (;) to be executed.
  • SQLPlus provides a command line interface, where SQL> is the prompt.

The above is the detailed content of Usage of sqlplus command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn