USE DATABASE command on SQL PLUS ORACLE 11gr1

laruffii picture laruffii · May 5, 2012 · Viewed 88.3k times · Source

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.

Answer

a_horse_with_no_name picture a_horse_with_no_name · May 5, 2012

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)