7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.

Slides:



Advertisements
Similar presentations
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
Advertisements

9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Data Definition Language (DDL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
1 Chapter 2: Creating and Modifying Database Tables.
Managing Schema Objects
Oracle Data Definition Language (DDL)
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Oracle for Software Developers. What is a relational database? Data is represented as a set of two- dimensional tables. (rows and columns) One or more.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
Chapter 6 Additional Database Objects
SQL data definition using Oracle1 SQL Data Definition using Oracle.
9 Copyright © 2005, Oracle. All rights reserved. Administering User Security.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Oracle Database Administration
Chapter 6 Additional Database Objects Oracle 10g: SQL.
7 Copyright © 2004, Oracle. All rights reserved. Administering Users.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
8 Copyright © 2005, Oracle. All rights reserved. Managing Data.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
Oracle 11g: SQL Chapter 4 Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Schema Objects.
6 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
1 Chapter 2: Creating and Modifying Database Objects.
Sql DDL queries CS 260 Database Systems.
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
2 Copyright © 2006, Oracle. All rights reserved. Managing Schema Objects.
SQL Overview Structured Query Language
Transactions, Roles & Privileges Oracle and ANSI Standard SQL Lecture 11.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Academic Year 2015 Autumn. MODULE CC2006NI: Data Modelling and Database Systems Academic Year 2015 Autumn.
Lecture # 24 Introduction to SQL Muhammad Emran Database Systems.
 CONACT UC:  Magnific training   
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
SQL Statements SELECT INSERTUPDATEDELETECREATEALTERDROPRENAMETRUNCATECOMMITROLLBACKSAVEPOINTGRANTREVOKE Data Retrieval Language (DRL) Data Retrieval Language.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Creating and Managing Tables. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically represents subsets.
13 Copyright © 2004, Oracle. All rights reserved. Migrating SQL Statements.
Relational Databases and SQL The relational model and the most common SQL commands.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
15 Copyright © Oracle Corporation, All rights reserved. Managing Users.
DATABASE MANAGEMENT SYSTEM
Managing Objects with Data Dictionary Views
SQL data definition using Oracle
Chapter 4 Indexes.
Oracle Data Definition Language (DDL)
Contents Preface I Introduction Lesson Objectives I-2
Presentation transcript:

7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects

7-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Compare schema objects and data types Create and modify tables Define constraints View the columns in a table View the contents of a table Create indexes and views Compare the use of temporary tables

7-3 Copyright © 2004, Oracle. All rights reserved. What Is a Schema? HR schema HR user owns

7-4 Copyright © 2004, Oracle. All rights reserved. Schemas Schemas created as part of the database creation process: SYS SYSTEM Sample schemas

7-5 Copyright © 2004, Oracle. All rights reserved. Schemas - Full Notes Page

7-6 Copyright © 2004, Oracle. All rights reserved. Accessing Schema Objects Click a link to access the schema objects.

7-7 Copyright © 2004, Oracle. All rights reserved. Oracle Database and SQL Server: Similarities Similar schema objects (tables, views) Similar data types Referential integrity Check constraints/rules Transaction support Triggers and stored subprograms SQL access to system catalog (data dictionary)

7-8 Copyright © 2004, Oracle. All rights reserved. Comparing Schema Objects Oracle schema objects not available in SQL Server: –Database link (SQL Server: stored procedure) –Profile –Materialized view –Sequence (SQL Server: Serial data type) –Synonym SQL Server rule, integrity, and default are implemented as constraints of Oracle tables.

7-9 Copyright © 2004, Oracle. All rights reserved. Naming Database Objects Names must be from 1 to 30 bytes long with these exceptions: –Names of databases are limited to 8 bytes. –Names of database links can be as long as 128 bytes. Nonquoted names cannot be Oracle-reserved words. Nonquoted names must begin with an alphabetic character from your database character set.

7-10 Copyright © 2004, Oracle. All rights reserved. Naming Database Objects Nonquoted names can contain only: –Alphanumeric characters from your database character set –The underscore (_) –Dollar sign ($) –Pound sign (#) No two objects can have the same name within the same namespace. MS Tip: OMWB assists with resolving naming conflicts.

7-11 Copyright © 2004, Oracle. All rights reserved. Schema Object Namespaces The following have their own namespace: Indexes Constraints Clusters Database triggers Private database links Dimensions The following are in the same namespace: Tables Views Sequences Private synonyms Stand-alone procedures Stand-alone stored functions Packages Materialized views User-defined types

7-12 Copyright © 2004, Oracle. All rights reserved. Specifying Data Types in Tables Common data types: CHAR(size) : Fixed-length character data of length size bytes VARCHAR2(size) : Variable-length character string having maximum length size bytes DATE : Valid date range from January 1, 4712 B.C. to A.D. December 31, 9999 NUMBER(p,s) : Number having precision p and scale s

7-13 Copyright © 2004, Oracle. All rights reserved. Other Data Types BINARY_FLOAT BINARY_DOUBLE FLOAT INTEGER NCHAR NVARCHAR2 LONG LONG RAW RAW ROWID UROWID BLOB CLOB NCLOB BFILE TIMESTAMP

7-14 Copyright © 2004, Oracle. All rights reserved. Other Data Types Full Notes Page

7-15 Copyright © 2004, Oracle. All rights reserved. Comparing Data Types SQL ServerOracle INTEGERNUMBER(10) SMALLINTNUMBER(6) TINYINTNUMBER(3) DECIMAL(p,[q])NUMBER(p,[q]) NUMERIC(p,[q])NUMBER(p,[q]) REALFLOAT FLOAT[(p)] BITNUMBER(1) CHAR(n) VARCHAR(n)VARCHAR2(n) NCHAR(n)CHAR(n*2) NVARCHAR(n)VARCHAR(n*2)

7-16 Copyright © 2004, Oracle. All rights reserved. Comparing Data Types SQL ServerOracle TEXTCLOB IMAGEBLOB BINARY(n)RAW(n), BLOB VARBINARY(n)RAW(n), BLOB DATETIMEDATE (or TIMESTAMP) SMALLDATETIMEDATE (with constraint) MONEYNUMBER(19,4) SMALLMONEYNUMBER(10,4) TIMESTAMPNUMBER SYSNAMEVARCHAR2(30)

7-17 Copyright © 2004, Oracle. All rights reserved. Creating and Modifying Tables Specify the table name and schema. Specify the column names, data types, and lengths.

7-18 Copyright © 2004, Oracle. All rights reserved. Creating and Modifying Tables Full Notes Page

7-19 Copyright © 2004, Oracle. All rights reserved. Understanding Data Integrity

7-20 Copyright © 2004, Oracle. All rights reserved. Understanding Data Integrity Full Notes Page

7-21 Copyright © 2004, Oracle. All rights reserved. Constraint States ENABLE NOVALIDATE ENABLE VALIDATE Existing dataNew data DISABLE NOVALIDATE DISABLE VALIDATE No DML

7-22 Copyright © 2004, Oracle. All rights reserved. Defining Constraints

7-23 Copyright © 2004, Oracle. All rights reserved. Constraint Checking DML statement, followed by: COMMIT ; Check nondeferred constraints COMMIT issued Check deferred constraints COMMIT complete

7-24 Copyright © 2004, Oracle. All rights reserved. Viewing the Columns in a Table

7-25 Copyright © 2004, Oracle. All rights reserved. Viewing the Contents of a Table

7-26 Copyright © 2004, Oracle. All rights reserved. Actions with Tables

7-27 Copyright © 2004, Oracle. All rights reserved. Actions with Tables Full Notes Page

7-28 Copyright © 2004, Oracle. All rights reserved. Creating Indexes

7-29 Copyright © 2004, Oracle. All rights reserved. What Is a View? A view is a customized representation of data in a table or view. Views do not contain data.

7-30 Copyright © 2004, Oracle. All rights reserved. Creating Views

7-31 Copyright © 2004, Oracle. All rights reserved. What Is a Sequence? Generating primary key values SQL Server: Serial data type Oracle: Sequence plus database trigger

7-32 Copyright © 2004, Oracle. All rights reserved. What Is a Sequence? Full Notes Page

7-33 Copyright © 2004, Oracle. All rights reserved. Using a Sequence

7-34 Copyright © 2004, Oracle. All rights reserved. Deleting a Table Dropping a table removes: Data Table structure Database triggers Corresponding indexes Associated object privileges Optional clauses for the DROP TABLE statement: CASCADE CONSTRAINTS: Dependant referential integrity constraints PURGE: No flashback possible DROP TABLE hr.employees PURGE ;

7-35 Copyright © 2004, Oracle. All rights reserved. Truncating a Table Truncating a table deletes all rows in a table and releases used space. Corresponding indexes are truncated. TRUNCATE TABLE hr.employees;

7-36 Copyright © 2004, Oracle. All rights reserved. Migration Considerations: Temporary Tables SQL Server: –Local temporary tables, names beginning with # –Global temporary tables, names beginning with ## –Not compatible with Oracle’s naming conventions Options in Oracle: –Temporary ANSI-style (global temporary) tables –Multitable joins (optimized internally) –Materialized views –PL/SQL tables

7-37 Copyright © 2004, Oracle. All rights reserved. Full Notes Page

7-38 Copyright © 2004, Oracle. All rights reserved. Creating Temporary Tables Use the GLOBAL TEMPORARY clause to create temporary tables. Tables retain data only for the duration of a transaction or session. DML locks are not acquired on the data. You can create indexes, views, and triggers on temporary tables. CREATE GLOBAL TEMPORARY TABLE hr.employees_temp AS SELECT * FROM hr.employees;

7-39 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Compare schema objects and data types Create and modify tables Define constraints View the columns in a table View the contents of a table Create indexes Compare the use of temporary tables

7-40 Copyright © 2004, Oracle. All rights reserved. Practice Overview: Administering Schema Objects This practice covers the following topics: Creating tables with columns Creating constraints: –Primary key –Check –Foreign key Creating indexes