Download Click install Installation Oracle 11g Express

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Tandem Computers wikipedia , lookup

Relational algebra wikipedia , lookup

DBase wikipedia , lookup

Microsoft Access wikipedia , lookup

Concurrency control wikipedia , lookup

Btrieve wikipedia , lookup

Database wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Clusterpoint wikipedia , lookup

Oracle Database wikipedia , lookup

Null (SQL) wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Transcript
Installation Oracle 11g Express
 double click the "setup" button to install the
Oracle.
2
Installation Oracle 11g Express
 Accept agreement and Click Next.
3
Installation Oracle 11g Express
 Choose the destination folder, then click next.
4
Installation Oracle 11g Express
 Enter and confirm the password for database, then click
next.
5
Installation Oracle 11g Express
 Click install
6
Installation Oracle 11g Express
 Wait until finish and Click on "finish".
7
Installation SQL developer
 There is no installation require. Copy the sql dveloper
folder and pasted to any directory you want.
 Double click the SqlDeveloper executable file
 The first time you launch Oracle SQL Developer you will
be promoted to tell it the location of your installed JDK.
8
Installation SQL developer
 The first time you launch Oracle SQL Developer you will
also be prompted to associate certain file types with it.
You should all file types and click ok.
9
Installation SQL developer
 Once it finishes launching, Oracle SQL Developer
should look like this. You may begin using it.
10
Post Installation: Create a database
connection
 We will create our first connection as the default
database administrator, SYSTEM. Follow the steps below
 Click on the green plus (+) in the Connections window
on the left side of the IDE.
11
Post Installation: Create a database
connection
 A popup window will display where you
can fill out all the required information
to create the connection. Type in the
data exactly as shown in the screenshot
below:
12
sys
dba
13
Post Installation: Create a database
connection
 Click Connect and you will be returned to the main
IDE screen and you are now connected to the 11g
Express Database as the SYSTEM user.
14
Unlocking the HR User
 Oracle 11g Express Edition has some demo database
users loaded into the default install.Once of these
users is named HR.
 To unlock the HR user so you can experiment with
it, do the following:
 Open SQL*Developer and open the connection for
system-xe that we created in the last section.
 After the SQL Worksheet displays, type command
15
Unlocking the HR User
Alter user hr identified by pwd account
unlock;
grant all privileges to hr;
16
What Is Oracle SQL Developer?
 Oracle SQL Developer is a graphical tool that enhances
productivity and simplifies database development tasks.
 You can connect to any target Oracle database schema by using
standard Oracle database authentication.
SQL Developer
17
SQL Developer 3.1 Interface
You must define
a connection to
start using SQL
Developer for
running SQL
queries on a
database schema.
18
Creating a Database Connection
1
3
19
2
To create a database connection, perform
the following steps:
1. On the Connections tabbed page, right-click
Connections and select New Connection.
20
2. In the New/Select Database Connection window, enter the
connection name. Enter the username, we use hr and
password of the schema that you want to connect to.
hr
xe
21
a. From the Role drop-down list, you can select either default
or SYSDBA. (You choose SYSDBA for the sys user or any
user with database administrator privileges.)
b. You can select the connection type as: Basic
22
Browsing Database Objects
Use the Connections Navigator to:
 Browse through many objects in a database schema
 Review the definitions of objects at a glance
24
Displaying the Table Structure
Use the DESCRIBE command to display the structure of a table:
25
Creating a Schema Object
 SQL Developer supports the creation of any schema object by:
 Executing a SQL statement in SQL Worksheet
 Using the context menu
 Edit the objects by using an edit dialog box or one of the many
context-sensitive menus.
 View the data definition language (DDL) for adjustments such as
creating a new object or editing an existing schema object.
26
Using the SQL Worksheet
Enter SQL
statements.
Results are
shown here.
27
Executing SQL Statements
Use the Enter SQL Statement box to enter single or multiple
SQL statements.
F9
F5
F5
F9
28
Saving SQL Scripts
1
3
29
Click the Save icon to save
your SQL statement to a
file.
The contents of the
saved file are visible
and editable in your
SQL Worksheet
window.
2
Identify a location,
enter a file name,
and click Save.
Executing Saved Script Files: Method 1
1. Use the Files tab to locate the script file that
you want to open.
2. Double-click the script to display the code in
the SQL Worksheet.
1
30
3
To run the code, click
either:
• Execute Script (F9), or
• Run Script (F5)
2
Select a connection
from the drop-down
list.
Executing Saved Script Files: Method 2
Use the @ command
followed by the
location and name of
the file that you want
to execute, and click
the Run Script icon.
The output from the
script is displayed on
the Script Output
tabbed page.
31
SQL Statements
32






SELECT
INSERT
UPDATE
DELETE
MERGE
Data manipulation language (DML)






CREATE
ALTER
DROP
RENAME
TRUNCATE
COMMENT
Data definition language (DDL)
 GRANT
 REVOKE
Data control language (DCL)
 COMMIT
 ROLLBACK
 SAVEPOIN
Transaction control
T
The Human Resources (HR)Schema
33
Using DDL Statements to Create and Manage Tables
Naming Rules
 Table names and column names:
 Must begin with a letter
 Must be 1–30 characters long
 Must contain only A–Z, a–z, 0–9, _, $, and #
 Must not duplicate the name of another object
owned by the same user
 Must not be an Oracle server–reserved word
34
CREATE TABLE Statement
 You must have:
 CREATE TABLE privilege
 A storage area
CREATE TABLE table_name
(column datatype [DEFAULT expr],
, ...);
35
Creating Tables
CREATE TABLE dept
(deptno NUMBER(2),
dname VARCHAR2(14),
loc
VARCHAR2(13),
create_date DATE DEFAULT SYSDATE);
DESCRIBE dept
36
Data Types
Data Type
Description
CHAR(size)
Fixed-length character data
NUMBER(p,s)
Variable-length numeric data
DATE
Date and time values
VARCHAR2(size)
37
Variable-length character data
Including Constraints
 Constraints enforce rules at the table level.
 Constraints prevent the deletion of a table if there
are dependencies.
 The following constraint types are valid:
 NOT NULL
 UNIQUE
 PRIMARY KEY
 FOREIGN KEY
 CHECK
38
Defining Constraints
CREATE TABLE [schema.]table
(column datatype [DEFAULT expr]
[column_constraint],
...
[table_constraint][,...]);
column [CONSTRAINT constraint_name] constraint_type,
column,...
[CONSTRAINT constraint_name] constraint_type
(column, ...),
39
Defining Constraints
CREATE TABLE emp(
employee_id NUMBER(6)
CONSTRAINT emp_emp_id_pk PRIMARY KEY,
first_name VARCHAR2(20),
1
...);
40
CREATE TABLE emp(
employee_id NUMBER(6),
first_name VARCHAR2(20),
...
job_id VARCHAR2(10) NOT NULL,
CONSTRAINT emp_emp_id_pk
PRIMARY KEY (EMPLOYEE_ID));
2
UNIQUE Constraint
CREATE TABLE emp(
employee_id
NUMBER(6) PRIMARY KEY,
last_name
VARCHAR2(25) NOT NULL,
email
VARCHAR2(25),
salary
NUMBER(8,2),
commission_pct NUMBER(2,2),
hire_date
DATE NOT NULL,
...
CONSTRAINT emp_email_uk UNIQUE(email));
41
FOREIGN KEY Constraint
 Defined at either the table level or the column level:
42
CREATE TABLE emp(
employee_id NUMBER(6) PRIMARY KEY,
last_name
VARCHAR2(25) NOT NULL,
email
VARCHAR2(25),
salary
NUMBER(8,2),
commission_pct NUMBER(2,2),
hire_date
DATE NOT NULL,
...
deptno NUMBER(4),
CONSTRAINT emp_dept_fk FOREIGN KEY (deptno)
REFERENCES dept(deptno),
CONSTRAINT emp_email_uk UNIQUE(email));
CHECK Constraint
 Defines a condition that each row must satisfy
..., salary
NUMBER(2)
CONSTRAINT emp_salary_min
CHECK (salary > 0),...
43
Creating a Table Using a Subquery
CREATE TABLE
dept80
AS
SELECT employee_id, last_name,
salary*12 ANNSAL,
hire_date
FROM
employees
WHERE
department_id = 80;
DESCRIBE dept80
44
Dropping a Table
 Moves a table to the recycle bin
 Removes the table and all its data entirely if the
PURGE clause is specified
DROP TABLE dept80;
45