Introduction to Oracle

Similar documents
Architecture. Architecture. Introduction to Oracle 10g Express Edition. Help

Introduction to IBM DB2

Oracle Database 10g Express

Full file at

Working with Columns, Characters and Rows. Copyright 2008, Oracle. All rights reserved.

Creating an Oracle Database

Lab # 4. Data Definition Language (DDL)

Creating and Managing Tables Schedule: Timing Topic

Lab # 1. Introduction to Oracle

Database Programming with SQL

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Installing Oracle Software

Database Programming with SQL

Oracle Database 10g: PL/SQL Fundamentals. Oracle Internal & Oracle Academy Use Only. Volume I Student Guide. D17112GC30 Edition 3.0 April 2009 D59413

CHAPTER. Planning and Managing Tablespaces

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Data Definition Language (DDL)

Oracle Database 11g: SQL Fundamentals I COPYRIGHTED MATERIAL. PArt

Oracle 12C DBA Online Training. Course Modules of Oracle 12C DBA Online Training: 1 Oracle Database 12c: Introduction to SQL:

SELF TEST. List the Capabilities of SQL SELECT Statements

Explore the Oracle 10g database architecture. Install software with the Oracle Universal Installer (OUI)

Oracle Tables TECHGOEASY.COM

Change Default Temporary Tablespace Usage Oracle 10g

Database Programming with PL/SQL

EDB Postgres Migration Portal Guide Version 1.0

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

Performing a 32 bit to 64 bit migration using the Transportable Database RMAN feature

ORACLE DBA TRAINING IN BANGALORE

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

VerifiedDumps. Get the Valid and Verified Exam Questions & Answers Dump for 100% Pass

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

Installing and Configuring Oracle 10g Express Edition. for use with the ETM System

Using DDL Statements to Create and Manage Tables. Copyright 2006, Oracle. All rights reserved.

CHAPTER. Oracle Database 11g Architecture Options

Oracle Database Administration

Steps how to duplicate a database to a new machine. Version 10gR2

Including Dynamic Images in Your Report

RETRIEVING DATA USING THE SQL SELECT STATEMENT

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.

MDCStore 2.0 DATABASE. Installation Guide

CHAPTER. Introduction

Managing Your Database Using Oracle SQL Developer

Item: 1 (Ref:Cert-1Z )

Oracle Migration Workbench

Database Administration and Management

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Oracle 1z z0-146 Oracle Database 11g: Advanced PL/SQL. Practice Test. Version QQ:

Database Design and Implementation

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

Course Contents of ORACLE 9i

Oracle Database: SQL and PL/SQL Fundamentals

Course Outline and Objectives: Database Programming with SQL

Physical Design of Relational Databases

Tablespace Usage By Schema In Oracle 11g Rac

Getting Information from a Table

Assignment 6. This lab should be performed under the Oracle Linux VM provided in the course.

Recovering Oracle Databases

DumpsKing. Latest exam dumps & reliable dumps VCE & valid certification king

Oracle SQL Developer. Oracle TimesTen In-Memory Database Support User's Guide Release 4.0 E

A Robust Blueprint to Performance Optimization in Multiblock Databases. Anthony D. Noriega.

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

chapter 2 G ETTING I NFORMATION FROM A TABLE

Oracle Database 10g: Introduction to SQL

CHAPTER. Getting Started with the Oracle Architecture

Using SQL Developer. Oracle University and Egabi Solutions use only

Database Programming with SQL

Lab4 - Managing Database Storage Structures Using Enterprise Manager Database Express

Oracle Database 12c: New Features for Administrators (40 hrs.) Prerequisites: Oracle Database 11g: Administration Workshop l

Creating an Oracle Database Using DBCA. Copyright 2009, Oracle. All rights reserved.

BraindumpsVCE. Best vce braindumps-exam vce pdf free download

ORANET- Course Contents

COMPARE THE PERFORMANCE OF BASICFILE VS SECUREFILE LOBS In order to check the performance of two types of LOBs format, we will perform the following

Database Programming with SQL

MDCStore High Content Data Management Solution Database Schema

Getting Started With Oracle

Question: Which statement would you use to invoke a stored procedure in isql*plus?

Oracle Application Express: Administration 1-2

Oracle CDC 调研报告 林子雨 北京大学计算机系数据库实验室 2006 年 11 月 10 日

Database Programming with SQL

2 PL/SQL - fundamentals Variables and Constants Operators SQL in PL/SQL Control structures... 7

Oracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)

Manually configuring Oracle 12c IBM

Change Default Temporary Tablespace Use Oracle 11g Create

Database Programming with SQL

Manual 12c Container Database

Oracle Database 12c Release 2

Manually create oracle 9i database in RedHat Linux Advanced Server 2.1 by M.B.G.Suranga De Silva

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Question: 1 Identify three components of an Oracle instance for which you can change the size dynamically. (Choose three.)

IBM Database Conversion Workbench 3.5

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Oracle Database 11g: Administration I

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

This document contains information on fixed and known limitations for Test Data Management.

"Charting the Course... Oracle 18c DBA I (3 Day) Course Summary

White Paper. Using SVA SnapShot With Oracle June, 2001 TL-ENG-PRD-0477-A1 TL-ENG-PRD-0477-A01

Guide to installing Oracle 10G Enterprise Edition Server (and creating databases) on Windows, for Controller 8.2

Transcription:

Introduction to Oracle

Architecture Client-server system Server: SERVEDB, Internal addess (from the lab) servedb.ing.man External address (from home with OpenVPN) 10.17.2.91 Client: Web interface: http:// servedb.ing.man:8080/apex Command line: sqlplus 2

Architecture A server can contain one or more databases Each database can have one or more instances An instance is a set of processes that access the data of the database Different from SQL Server/DB2 Objects are contained in databases: table, views, stored procedures Objects are divided into schemas One schema per user with the name of the user No other schemas (different from SQL Server/DB2) On server SERVEDB only one database, only one instance Oracle Express allows only one database per server Accessible at http://10.17.2.91:8080/apex 3

Help Local help: http://servedb.ing.man/:8080/apex/wwv_flow_help.show _help?p_flow_id=4500&p_step_id=1000 Web help: http://www.oracle.com/pls/xe102/homepage http://www.oracle.com/pls/db102/homepage 4

Connecting Launch browser Go to http://servedb.ing.man:8080/apex Insert: Username: hr Password: Infonew1 5

Browsing Objects On the Database Home Page, click the Object Browser icon. The Object Browser page displays with two sections: The Object Selection and the Detail pane Click the EMPLOYEES table in the Tables object list to display information about the structure of that table. 6

Connecting with the command line Run SQL Command Line from the start menu or start a command window and type: SQLPLUS /NOLOG CONNECT username/password@[//]host[:port][/service_name] // is optional host is the host name or IP address of the computer that is running Oracle Database XE port (optional) is the TCP port number on which the Oracle Net listener is listening. If not specified, the default port number 1521 is assumed. service_name (optional) is the name of the database service to which to connect. For Oracle Database XE, the service name is XE. If service_name is omitted, Oracle Database XE Client appends a request for the default database service, which is configured during installation as XE. 7

Connecting with the command line Example: CONNECT hr/infonew1@servedb.ing.man DISCONNECT to disconnect 8

Issuing SQL Commands SELECT EMPLOYEE_ID,FIRST_NAME,LAST_NAME FROM EMPLOYEES; EMPLOYEE_ID FIRST_NAME LAST_NAME ----------- -------------------- ------------------------- 100 Steven King 101 Neena Kochhar 102 Lex De Haan 103 Alexander Hunold 104 Bruce Ernst 105 David Austin 106 Valli Pataballa 107 Diana Lorentz 108 Nancy Greenberg 9

Ending a SQL Command You can end a SQL command in one of three ways: with a semicolon (;) with a slash (/) on a line by itself with a blank line A semicolon (;) tells SQL*Plus that you want to run the command. Type the semicolon at the end of the last line of the command and press Return. SQL*Plus processes the command and also stores the command in the SQL buffer. A slash (/) on a line by itself also tells SQL*Plus that you wish to run the command. SQL*Plus executes the command and stores it in the buffer. A blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet. 10

Authentication Oracle uses user accounts separated from those of the operating system A user account is identified by a user name and defines the user's attributes, including the following: Password for database authentication Privileges and roles Default tablespace for database objects Default temporary tablespace for query processing work space When you create a user, you are also implicitly creating a schema for that user. 11

Privileges There are two main types of user privileges: System privileges A system privilege is the right to perform a particular action, or to perform an action on any schema objects of a particular type. For example, the privileges to create tables and to delete the rows of any table in a database are system privileges. Object privileges An object privilege is a right to perform a particular action on a specific schema object. 12

Roles Managing and controlling privileges is made easier by using roles, which are named groups of related privileges. You create roles, grant system and object privileges to the roles, and then grant roles to users. Unlike schema objects, roles are not contained in any schema. 13

Predefined Roles CONNECT: Enables a user to connect to the database. RESOURCE: Enables a user to create certain types of schema objects in his own schema. Grant this role only to developers and to other users that must create schema objects. DBA: Enables a user to perform most administrative functions, including creating users and granting privileges; creating and granting roles; creating and dropping schema objects in other users' schemas; and more. 14

Internal User Accounts Certain user accounts are created automatically for database administration. Examples are SYS and SYSTEM. These automatically created accounts are called internal user accounts, and their schemas are called internal schemas. 15

Internal User Accounts SYSTEM: This is the user account that you log in with to perform all administrative functions other than starting up and shutting down the database. SYS: All base tables and views for the database data dictionary are stored in the SYS schema. 16

Authentication Oracle uses OS authentication for starting and stopping the database Starting and shutting down: to be done on the server computer logged as a member of a special grounp with a command from the menu or from the command line Windows: ORA_DBA user group. Tiplically Administrator is part of it Linux: dba user group OS authentication is needed because there must be a way to identify administrative users even if the database is shut down. 17

Names Every database object has a name. In a SQL statement, you represent the name of an object with a quoted identifier or a nonquoted identifier. A quoted identifier begins and ends with double quotation marks ("). If you name a schema object using a quoted identifier, then you must use the double quotation marks whenever you refer to that object. A nonquoted identifier is not surrounded by any punctuation. 18

Names The following list of rules applies to both quoted and nonquoted identifiers unless otherwise indicated: Names must be from 1 to 30 bytes long with this exception: Names of databases are limited to 8 bytes. 19

Names Nonquoted identifiers cannot be Oracle reserved words. Nonquoted identifiers must begin with an alphabetic character from the database character set. Quoted identifiers can begin with any character. 20

Names Nonquoted identifiers can contain only alphanumeric characters from your database character set and the underscore (_), dollar sign ($), and pound sign (#). Quoted identifiers can contain any characters and punctuations marks as well as spaces. Neither quoted nor nonquoted identifiers can contain double quotation marks or the null character (\0). Nonquoted identifiers are not case sensitive. Oracle interprets them as uppercase. Quoted identifiers are case sensitive. 21

Names Within a namespace, no two objects can have the same name. Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the same name. Each schema in the database has its own namespaces for the objects it contains. This means, for example, that two tables in different schemas are in different namespaces and can have the same name. 22

Names Examples The following examples are valid schema object names: last_name_horse "EVEN THIS & THAT!" a_very_long_and_valid_name Invalid: a_very_very_long_and_valid_name 23

Naming Guidelines Use the same names to describe the same things across tables. For example, the department number columns of the sample employees and departments tables are both named department_id. 24

Case Sensitiveness Case is insignificant in reserved words, keywords, identifiers and parameters. However, case is significant in text literals and quoted names. 25

Physical Database Structures Every database has one or more physical datafiles. The datafiles contain all the database data. The characteristics of datafiles are: A datafile can be associated with only one database. Datafiles can have certain characteristics set to let them automatically extend when the database runs out of space. 26

Physical Database Structures Every Oracle database has a control file. A control file contains entries that specify the physical structure of the database. For example, it contains the following information: Database name Names and locations of datafiles and redo log files Time stamp of database creation 27

Physical Database Structures Every Oracle database has a set of two or more redo log files. The set of redo log files is collectively known as the redo log for the database. To protect against a failure involving the redo log itself, Oracle allows a multiplexed redo log so that two or more copies of the redo log can be maintained on different disks 28

Logical Database Structures A database is divided into logical storage units called tablespaces, which group related logical structures together. For example, tablespaces commonly group together all application objects to simplify some administrative operations. 29

Tablespaces Each database is logically divided into one or more tablespaces. One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace. The combined size of the datafiles in a tablespace is the total storage capacity of the tablespace. 30

Tablespaces A bigfile tablespace is a tablespace with a single, but very large (up to 4G blocks) datafile. Smallfile tablespaces, in contrast, can contain multiple datafiles, but the files cannot be as large. Bigfile tablespaces let Oracle utilize the ability of 64- bit systems to create and manage ultralarge files. In this way Oracle can scale up to 8 exabytes in size. 31

Logical Database Structures Every Oracle database contains a SYSTEM tablespace and a SYSAUX tablespace. Created automatically when the database is created. The system default is to create a smallfile tablespace The SYSTEM and SYSAUX tablespaces are created as smallfile tablespaces. 32

Database Creation Example CREATE DATABASE mynewdb USER SYS IDENTIFIED BY pz6r58 USER SYSTEM IDENTIFIED BY y1tz5p --The password for user SYS is pz6r58 and the password for SYSTEM is y1tz5p. LOGFILE GROUP 1 ('/u01/oracle/oradata/mynewdb/redo01.log') SIZE 100M, GROUP 2 ('/u01/oracle/oradata/mynewdb/redo02.log') SIZE 100M, GROUP 3 ('/u01/oracle/oradata/mynewdb/redo03.log') SIZE 100M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 --The new database has three redo log files -- MAXLOGFILES, MAXLOGMEMBERS, and MAXLOGHISTORY define limits for the redo log. 33

Database Creation Example MAXDATAFILES 100 -- MAXDATAFILES specifies the maximum number of datafiles that can be open in the database. MAXINSTANCES 1 -- only one instance can have this database mounted and open. CHARACTER SET US7ASCII NATIONAL CHARACTER SET AL16UTF16 --The AL16UTF16 character set is used to store data in columns specifically defined as NCHAR, NCLOB, or NVARCHAR2. 34

Database Creation Example DATAFILE '/u01/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL --The SYSTEM tablespace, consisting of the operating system file /u01/oracle/oradata/mynewdb/system01.dbf is created as specified by the DATAFILE clause. If a file with that name already exists, it is overwritten. 35

Database Creation Example SYSAUX DATAFILE '/u01/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE -- A SYSAUX tablespace is created, consisting of the operating system file /u01/oracle/oradata/mynewdb/sysaux01.dbf DEFAULT TABLESPACE tbs_1 --Clause creates and names a default permanent tablespace for this database. 36

Data Types Character datatypes Numeric datatypes Date and time (date-time) datatypes Large Object (LOB) datatypes 37

Character datatypes The VARCHAR2 datatype stores variable-length character literals. Length between 1 and 4000 bytes The CHAR datatype stores fixed-length character literals. Length: between 1 and 2000 bytes NCHAR and NVARCHAR2 datatypes store Unicode character data. 38

Numeric NUMBER: as DECIMAL in SQL Server and DB2 BINARY_FLOAT, BINARY_DOUBLE: store floatingpoint data in the 32-bit IEEE 754 format and the double precision 64-bit IEEE 754 format respectively. Compared to the NUMBER datatype, arithmetic operations on floating-point data are usually faster for BINARY_FLOAT and BINARY_DOUBLE. High-precision values require less space when stored as BINARY_FLOAT and BINARY_DOUBLE datatypes.. 39

Date and Time DATE: century, year, month, day, hours, minutes, and seconds. TIMESTAMP: values that are precise to fractional seconds TIMESTAMP WITH TIME ZONE: datatype can also store time zone information 40

Large Objects (LOBs) A set of datatypes that are designed to hold large amounts of data. A LOB can hold up to a maximum size ranging from 8 terabytes to 128 terabytes The BLOB, CLOB, and NCLOB datatypes are internal LOB datatypes and are stored in the database. The BFILE datatype is the only external LOB datatype and is stored in an operating system file, outside the database. 41

Creating a Table with the Object Browser Log in with: Username: Utente Password: Infonew1 On the Database Home Page, click the Object Browser icon. In the object list under Create, select Table. Table name: personal_info_numero_di_matricola 42

Creating a Table with the Object Browser Columns employee_id NUMBER(6,0) NOT NULL birth_date DATE NOT NULL social_security_id VARCHAR2(12) NOT NULL marital status VARCHAR2(10) dependents_claimed NUMBER(2,0) contact_name VARCHAR2(45) NOT NULL contact_phone VARCHAR2(20) NOT NULL contact_address VARCHAR2(80) NOT NULL 43

Creating a Table with the Object Browser After you have entered the column information, click Next. On the Primary Key page, do not create a key at this time. Click the Next button On the Foreign Key page, do not create a key at this time. Click the Next button. On the Constraints page, do not create a constraint at this time. Click the Finish button. On the Create Table page, click the SQL button to view the SQL statements that produce the table. This option shows the statement even if it is incomplete. You need to complete your input to see the complete SQL statement when using this option. Click the Create button to create the table. 44

Adding a Column To a Table You can use Object Browser to add columns to a table. On the Database Home Page, click the Object Browser icon. In the Object list, select Tables and then click the personal_info table that you previously created. Click Add Column. 45

Altering a Table Modifying a Column In a Table Dropping a Column From a Table Adding a Check Constraint Adding a Unique Constraint Adding a Primary Key Constraint Adding a Foreign Key Constraint Similar 46