About SQL and SQL-Based Management Tools

About SQL and SQL-Based Management Tools

To perform many of its operations, Oracle Enterprise Manager Database Control (Database Control) submits structured query language (SQL) statements to the database. SQL (pronounced like sequel) is an industry-standard English-like computer programming language for querying and updating databases.
为执行许多的操作,数据库控制台向数据库提交sql语句。sql语句是一个为查询或更新数据库的英语化的工业标准计算机编程语言。

The following is an example of a SQL query that lists information about countries in a countries table, which is owned by user hr:
下面是一个sql查询的例子,列出属于hr用户的国家表的内容。

SELECT COUNTRY_ID, COUNTRY_NAME FROM HR.COUNTRIES;

SQL is a powerful language that can also be used to perform a variety of database administration tasks. The following SQL statement creates the database user nick and assigns him a password of your choosing, represented by password:
sql的功能很强大,可以执行各种的数据库管理任务。下面的sql语句创建一个数据库用户nick并且分配一个密码,把密码写在下面password处。

CREATE USER nick IDENTIFIED BY password;

When performing an administrative task in Database Control, you can click Show SQL to see the SQL statements that Database Control generates and submits.
当在控制台执行一个管理任务时,你可以点击 Show SQL,查看控制台生成并提交的sql语句。

In addition to using the graphical management pages presented in Database Control, you can use other Oracle tools such as SQL Developer and SQL*Plus to issue SQL statements. These tools enable you to perform database management operations, and to query, insert, update, or delete data directly in the database. The following sections provide details:
除了图形化界面的控制台之外,还可以用其它的oracle工具,如SQL Developer和SQL*Plus来发布sql命令。这些工具能让你执行数据库的管理操作,可以直接在数据库中进行增、删、改、查等操作。下面详细讲述:

About SQL*Plus

SQL*Plus is a command-line program that you use to submit SQL and PL/SQL statements to an Oracle database. You can submit statements interactively or as SQL*Plus scripts. SQL*Plus is installed with the database and is located in your Oracle_home/bin directory.
SQL*Plus是一个命令行程序用来向oracle数据库提交sql和PL/SQL语句的。你可以交互式的提交语句,或者写成SQL*Plus脚本。SQL*Plus程序和数据库一起安装,路径在Oracle_home/bin

You can start SQL*Plus from the command line, or on Microsoft Windows, from the Start menu.
你可以从命令行启动SQL*Plus,或者在Windows系统从开始菜单启动。

When SQL*Plus loads, it issues the SQL prompt, which looks like this:
当SQL*Plus加载的时候,会出现像这样的SQL提示:

SQL>

At the SQL prompt, you can enter statements that perform administrative tasks such as shutting down the database or creating a new user, or you can query, insert, update, and delete data.
在sql提示行,可以输入执行管理任务的语句,如关闭数据库或者创建新用户或增、删、改查数据等。

You can enter a single SQL statement on multiple lines. You must end each statement with a semicolon (;). For most statements, you can rerun a statement by entering a forward slash (/) on a line by itself.
可以把一个sql语句写在多行中。每条语句要以分号(;)结尾。大部分语句都可以用“/”重复执行。

Starting SQL*Plus and Connecting to the Database

The section describes how to start SQL*Plus and connect to the database from both the command line and the Windows start menu.
这段主要说如何从命令行和windows开始菜单启动SQL*Plus连接数据库。

To start SQL*Plus and connect to the database from the command line:

  1. Open a command window.

  2. (Linux and UNIX systems only) Set the required environment variables (ORACLE_HOME and ORACLE_SID) by running the script oraenv (for the Bourne, Korn, or Bash shell) or coraenv (for the C shell).

    These scripts are typically located in the /usr/local/bin directory. They may prompt you for the desired value of the ORACLE_SID environment variable. If so, supply the system ID (SID) that you chose when you installed Oracle Database. The default SID that the installer typically suggests is orcl.
    这些脚本一般都会在/usr/local/bin directory路径中。会提示你需要ORACLE_SID环境变量。如果提示的话,请提供在安装的时候指定的SID。默认的SID是orcl。

  3. (Linux and UNIX systems only) Either ensure that the Oracle_home/bin directory is in your PATH environment variable, or change to the Oracle_home/bin directory.
    (仅在Linux和UNIX系统)确认Oracle_home/bin路径在PATH环境变量中,没有的话在PATH加入Oracle_home/bin

  4. Enter the following command:
    输入下面的命令:

    sqlplus {username | /} [as sysdba]
    Enter password: password
    

    SQL*Plus connects you to the default database instance (Microsoft Windows) or the database instance specified by the environment variables (Linux and UNIX).
    在windows系统中SQL*Plus命令会连接到默认的数据库实例中,在Linux或UNIX系统中会连到你指定的实例中。

    For username, you can use the SYS or SYSTEM administrative users. At the prompt, enter the password that you set up during installation. If you use the SYS user, you must include as sysdba after the username.
    就username而言,你可以用SYS或SYSTEM管理员用户。在提示行输入安装的时候管理员密码。如果你用SYS用户,必须在用户名后面跟上as sysdba

    When you enter SYS or a slash (/) as the user name and provide the as sysdba clause, you are authenticating using operating system authentication. Operating system authentication uses your Windows, UNIX, or Linux host user account to authenticate you to Oracle Database. You must have logged in to the host computer with a user account that is a member of a special host user group. On UNIX and Linux, this user group is typically dba. This type of authentication enables you to connect to an Oracle database that is not yet started, so that you can start it up. See Oracle Database Administrator's Guide for more information.
    当你输入SYS或者一个斜线(/)作为用户名并且后面跟着as sysdba子句,这会用操作系统认证来认证你的登录权限。操作系统认证是用你的主机的用户来认证你登录数据库权限。你需要用主机的特殊用户组的用户登录主机。在UNIX和Linux系统,这个用户组一般是dba。这种类型的认证即使数据库还没有启动也允许你连接到oracle数据库,从而启动数据库。更多信息参见 Oracle Database Administrator's Guide

To start SQL*Plus and connect to the database from the Windows Start menu:

  1. Click Start, select Programs (or All Programs), then Oracle - HOME_NAME, then Application Development, and then SQL*Plus.

  2. When prompted, enter the user name and password for the account that you want to use to connect to the database.

    For the user name, you can use the SYS or SYSTEM administrative accounts, and you can use the password that you set up during installation.

    If you use SYS or / as the user name, follow them with a space and then the clause as sysdba, as shown in the following examples:

    Enter user-name: sys as sysdba
    Enter password: password
    
    or
    
    Enter user-name: / as sysdba
    

    When you enter SYS or a slash (/) as the user name and provide the as sysdba clause, you are authenticating using operating system authentication. Operating system authentication uses your Windows, UNIX, or Linux host user account to authenticate you to Oracle Database. You must have logged in to the host computer with a user account that is a member of a special host user group. On UNIX and Linux, this user group is typically dba for the sysdba privilege. This type of authentication enables you to connect to an Oracle database that is not yet started, so that you can start it up. See Oracle Database Administrator's Guide for more information.
    当你输入SYS或者一个斜线(/)作为用户名并且后面跟着as sysdba子句,这会用操作系统认证来认证你的登录权限。操作系统认证是用你的主机的用户来认证你登录数据库权限。你需要用主机的特殊用户组的用户登录主机。在UNIX和Linux系统,这个用户组一般是dba。这种类型的认证即使数据库还没有启动也允许你连接到oracle数据库,从而启动数据库。更多信息参见 Oracle Database Administrator's Guide

About SQL Developer

SQL Developer provides another graphical user interface for accessing your Oracle database. SQL Developer supports development in both the SQL and PL/SQL languages. It is available in the default installation of Oracle Database.

With SQL Developer, you can browse database objects, run SQL statements and SQL scripts, and edit and debug PL/SQL statements. You can also run any number of provided reports, as well as create and save your own.

See Also:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值