Home  >  Article  >  Database  >  How to read database in oracle

How to read database in oracle

下次还敢
下次还敢Original
2024-04-02 11:24:17936browse

How to run queries in Oracle database? Open a command prompt and connect to the database. Enter the command select * from table_name, where table_name is the name of the table to be queried.

How to read database in oracle

How to read Oracle database

Open command prompt

  1. In Windows, press Windows key R, type "cmd" and press Enter.
  2. In macOS, open the Terminal application.
  3. In Linux, open a terminal window.

Connect to the database

  1. Enter the following command:
<code>sqlplus username/password\@servername:port/servicename</code>
  • username:Your database username.
  • password: Your database password.
  • servername: The name or IP address of the database server.
  • port:Port number of the database (default port is 1521).
  • servicename: Database service name.

Example:

<code>sqlplus scott/tiger@localhost:1521/xe</code>

Run the query

After connecting to the database, you can run queries to retrieve data .

  1. Enter the following command:
<code>select * from table_name;</code>
  • table_name: The name of the table to be queried.

Example:

<code>select * from emp;</code>

Other useful commands

  • desc Table name: Display the structure of the table.
  • insert into table name (field name 1, field name 2, ...) values ​​(value 1, value 2, ...): Insert a new record.
  • update table name set field name 1 = value 1, field name 2 = value 2, ... where condition; : Update record.
  • delete from table name where condition: Delete records.

The above is the detailed content of How to read database in oracle. 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