Home > Database > SQL > body text

Usage of sqlplus command

小老鼠
Release: 2024-05-07 17:12:19
Original
902 people have browsed it

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>
Copy after login
  • 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>
    Copy after login
  • Query data

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

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

    <code>SQL> DISCONNECT</code>
    Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template