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 Oracle database
Open command prompt
- In Windows, press Windows key R, type "cmd" and press Enter.
- In macOS, open the Terminal application.
- In Linux, open a terminal window.
Connect to the database
- Enter the following command:
<code>sqlplus username/password\@servername:port/servicename</code>
Copy after login
-
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>
Copy after login
Run the query
After connecting to the database, you can run queries to retrieve data .
- Enter the following command:
<code>select * from table_name;</code>
Copy after login
-
table_name: The name of the table to be queried.
Example:
<code>select * from emp;</code>
Copy after login
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!