在 SQL PLUS ORACLE 11gr1 上使用 DATABASE 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10461861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
USE DATABASE command on SQL PLUS ORACLE 11gr1
提问by laruffii
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.
在Windows7 32位平台上成功安装ORACLE 11gR1后,我可以进入SQL PLUS,也可以创建数据库,但我仍然不知道如何使用数据库。
in MySQL the command to use database should be:
在 MySQL 中,使用数据库的命令应该是:
USE MYDATBASENAME;
In SQL SERVER also quite the same:
在 SQL SERVER 中也完全一样:
USE [DATABASE];
But I have no idea how to use database in ORACLE 11gR1 via SQLPLUS, any body have any ideas?
但我不知道如何通过 SQLPLUS 在 ORACLE 11gR1 中使用数据库,任何人有任何想法吗?
I'm planning to create a table after I succeed in using the USE
command.
我打算在成功使用该USE
命令后创建一个表。
回答by a_horse_with_no_name
Even though they all use the same noun the term "database" is something completely different between MySQL (SQL Server) and Oracle.
尽管它们都使用相同的名词,但术语“数据库”在 MySQL (SQL Server) 和 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.
通常,MySQL 数据库映射到 Oracle 中的架构/用户。在 Oracle 中,模式和用户之间存在 1:1 的关系。
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.
Oracle 中的“数据库”是指完整安装(也称为“实例”)。由于通常只有一个实例/安装,因此在 Oracle 中“切换数据库”是没有意义的。
The closest thing to "USE mydatabase" in Oracle would be to switch the current schema:
在 Oracle 中最接近“使用 mydatabase”的是切换当前模式:
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)
然后您可以访问所有表,other_user
而无需为它们添加前缀。这当然要求您的当前用户至少对其他用户的表(即架构)具有选择权限
回答by Satya
you can login into oracle using sqlplusw username/password@connect-string
and then do a select * from v$database
您可以使用登录到oraclesqlplusw username/password@connect-string
然后执行select * from v$database
use select instance_name from v$instance;
to find out which database are you currently connected to
用于select instance_name from v$instance;
找出您当前连接到哪个数据库
回答by beck03076
TNSNAMES.ora has the details about which database you are connecting to.
TNSNAMES.ora 包含有关您要连接到哪个数据库的详细信息。