Oracle Database Creating an import
By the Alma created, last modified 2018-06-04 14:37:50
In this chapter tutorial that will teach you how Oracle created into the database.
Note: This tutorial Some commands that you may not be familiar, but it does not matter, just follow the instructions step by step to create a sample database. After the tutorial, each command will be described in detail.
Create new users and grant permissions
First, start SQL plus program command line:
sqlplus
As follows:
Or open the Start menu from the installation directory of SQL Plus :
When SQL Plus starts, it will prompt you to enter a user name and password. Continue to be used in the installation Oracle enter the password to the database server during sys Log:
C:\Users\Administrator>sqlplus
* Plus SQL: Release 11.2.0.1.0 Production's ON Friday 11 Yue 10 04:32:17 2017
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Please enter your user name : SYS AS sysdba
Password :
Then, using the following CREATE USER statement creates a new user: OT , may be used to create the sample database into the database:
SQL> CREATE USER OT IDENTIFIED BY Orcl1234;
User created.
The above statement creates a file called : OT new users, and IDENTIFIED BY specify a password after clause, in this example, you create a user: OT corresponding password: Orcl1234 .
Then, by using the following GRANT to grant statement OT user rights:
SQL> GRANT CONNECT, RESOURCE, DBA TO OT;
Grant succeeded.
Sign in New account
Use OT connect to the database user account (ORCL) . When SQL Plus when prompted for a user name and password, enter: OT and Orcl1234 .
For the Oracle 11g / 12c , the following command:
SQL> CONNECT ot@orcl
Password :
connected.
Note, OT user exists only ORCL database, therefore, must clearly specify the user name ot @ orcl in the CONNECT command.
Create a database table
To create a sample database table, you need the plus SQL execution ot_schema.sql file statements
In SQL plus execution file SQL statement, you can use the following command ( syntax ) :
SQL> @path_to_sql_file
Assume ot_schema.sql file is located in F: \ website \ oraok \ ot directory, execute the following statement:
SQL>@F:\website\oraok\ot\11g\ot_schema.sql
After the completion of the implementation of the statement, you can list the OT to verify that the tables successfully create a table owned by the user. The following is a statement to do so:
SQL> SELECT table_name FROM user_tables ORDER BY Table_name;
TABLE_NAME------------------------------
CONTACTS
COUNTRIES
CUSTOMERS
EMPLOYEES
INVENTORIES
LOCATIONS
ORDERS
ORDER_ITEMS
PRODUCTS
PRODUCT_CATEGORIES
REGIONS
TABLE_NAME------------------------------
WAREHOUSES
We have selected 12 lines.
SQL>
In this statement, we from user_tables choose the table table_name value in the column, in alphabetical order of the table name. As seen in the results, there are 12 is the table name returned as expected.
Next, we can load the data / into these tables.
To load data into the table
To load data into the table, executed in the following ot_data.sql file statement:
SQL>@F:\website\oraok\ot\11g\ot_data.sql
If you do not see any error messages, it means that the data has been loaded successfully imported.
You can also use the SELECT statement to verify that the data has been loaded successfully imported. For example, to get contacts the number of rows in the table, use the following statement:
SQL> SELECT COUNT(*) FROM contacts;
COUNT(*)----------
319
SQL> SELECT COUNT(*) FROM countries;
COUNT(*)----------
25
SQL> SELECT COUNT(*) FROM customers;
COUNT(*)----------
319
SQL> SELECT COUNT(*) FROM employees;
COUNT(*)----------
107
SQL> SELECT COUNT(*) FROM inventories;
COUNT(*)----------
1112
SQL> SELECT COUNT(*) FROM locations;
COUNT(*)----------
23
SQL> SELECT COUNT(*) FROM orders;
COUNT(*)----------
105
SQL> SELECT COUNT(*) FROM order_items;
COUNT(*)----------
665
SQL> SELECT COUNT(*) FROM product_categories;
COUNT(*)----------
5
SQL> SELECT COUNT(*) FROM products;
COUNT(*)----------
288
SQL> SELECT COUNT(*) FROM regions;
COUNT(*)----------
4
SQL> SELECT COUNT(*) FROM warehouses;
COUNT(*)----------
9
The query returns 319 represents contacts table has 319 rows. By replacing the table with another table ( contacts ) you can check all the data in the table. If this is your first time using the database system, which is a good exercise for you.
To delete a table top model, execute:
SQL>@F:\website\oraok\ot\11g\ot_drop.sql