Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USE DATABASE command on SQL PLUS ORACLE 11gr1

Tags:

After successfully installing ORACLE 11gR1 on Windows7 32bit platform, I can go inside the SQL PLUS and I can also create database, but I still don't have any clue how to use database.

in MySQL the command to use database should be:

USE MYDATBASENAME; 

In SQL SERVER also quite the same:

USE [DATABASE]; 

But I have no idea how to use database in ORACLE 11gR1 via SQLPLUS, any body have any ideas?

I'm planning to create a table after I succeed in using the USE command.

like image 928
laruffii Avatar asked May 05 '12 12:05

laruffii


People also ask

How do I switch to a database in Oracle?

To set up and use a database switching service: Configure DataSources that connect to your live and staging databases. Configure a SwitchingDataSource component, as described in Configuring a SwitchingDataSource. Configure the Repository components that use the DataSources to point to the SwitchingDataSource .

How do I view a database in SQL Plus?

In terms of architecture, Oracle has table->schema->database, and at the same time also table->tablespace->database. MySQL has simply table->database.


1 Answers

Even though they all use the same noun the term "database" is something completely different between MySQL (SQL Server) and Oracle.

Usually a MySQL database is mapped to a schema/user in Oracle. In Oracle there is a 1:1 relationship between schemas and users.

A "database" in Oracle refers to the complete installation (which is also named "instance"). As there is typically only a single instance/installation there is no sense in "switching a database" in Oracle.

The closest thing to "USE mydatabase" in Oracle would be to switch the current schema:

ALTER SESSION SET current_schema = other_user; 

Then you can access all tables of other_user without prefixing them. This of course requires your current user to have at least select privileges on the tables of the other user (i.e schema)

like image 150
a_horse_with_no_name Avatar answered Sep 19 '22 17:09

a_horse_with_no_name