* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Narration Script: Slide 1: Oracle Database 11g Express Edition
Survey
Document related concepts
Microsoft Access wikipedia , lookup
Concurrency control wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Oracle Database wikipedia , lookup
Functional Database Model wikipedia , lookup
Ingres (database) wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Clusterpoint wikipedia , lookup
ContactPoint wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Transcript
Narration Script: Slide 1: Oracle Database 11g Express Edition – Working with Database Objects Hello and welcome to this online, self-paced course titled Oracle Database 11g Express Edition – Working with Database Objects. My name is Anupama Mandya, and I am part of Oracle Corporation’s Curriculum Development team. This course is part of Oracle Database 11g Express Edition New Features Self-Study series. In this course, using demonstrations, I will be discussing Working with Database Objects using Oracle SQL Command Line Utility and Oracle SQL Developer tools. This course is presented in two parts. Slide 2: Using The Player Script Before we begin, take a look at some of the features of this Flash-based course player. If you’ve attended similar Oracle eStudy courses in the past then, feel free to skip this slide. To your left, you will find a hierarchical course outline. This course enables and even encourages you to go at your own pace, which means you are free to skip over topics you already feel confident on, or jump right to a feature that really interests you, or go back and review topics that were already covered. Simply click on a course section to expand its contents and then select an individual slide. However, note that by default we will automatically walk you through the entire course without requiring you to use the outline. To the right of the course outline tab is the transcripts tab, which contains any additional reference notes for the current slide. Feel free to read these reference notes at the conclusion of the course. Or if you prefer you can read them as we go along. The third tab in the left panel is where you can search for content in this course. Standard Flash player controls are also found at the bottom of the player, including pause, previous, and next buttons. There is also an interactive progress bar to fast forward or rewind the current slide. Interactive slides may have additional controls and buttons along with instructions on how to use them. To the right of the standard Flash player controls is the Full Screen control. Click on it once to hide the course outline panel, and click it again to maximize the course display. This may be useful when viewing videos and demos embedded in the course. The course will now pause, so feel free to take some time and explore the interface. Then when you’re ready to continue, click the next button below or alternatively click the next slide in the course outline on the left. Slide 3: About This Course So, you know the title of the course, but you may be asking yourself “Am I in the right place?” To help you answer these questions you can answer information here regarding the course objectives, target audience and the prerequisites. When finished, click the “Next Topic” button. Slide 4 : Road Map In the first topic, we set up the working environment for this course. Slide 5: What to do First First, you need to perform some operations to setup the environment for the topics that follow. This includes setting up database administration accounts, regular database users and seeding some initial data into tables in the Express Edition database. In this topic, you learn how to create administration and database users, and load some employee data into the Express Edition database. Create a New Administration Account: An account named SYSTEM is created during the installation process. This account is considered an administrator account because it has DBA access. Using this account, you can create your own new administrator account and password so that you can create other database user accounts when needed. You log in with the administrative accounts to create and manage other user accounts and to maintain database security. Create a New Database User Account: You must create at least one database user that you will use to create database objects. A database user is a type of database object. A user is associated with a database schema, you connect to the database as a database user, and the database user is the owner of any database objects (tables and so on) that you create in the schema associated with the user. Load Data: To seed sample data into 11g Express Edition Database, load a sample script called load_sample.sql into the database. This is available in the Attachments tab of this course. This script contains information about each employee and about that employee's department which you might use to understand and work with the various topics that we will be discussing in this course. Slide 6: Here are the demonstrations of Creating a New Administration Account and Creating a new Database User and loading a sample script into the database. Slide 10: Road Map: In the next topic, we discuss about Creating and Managing Tables within the Database Slide 11: Creating and Managing Tables Oracle Database 11g Express Edition provides an organized mechanism for storing, managing, and retrieving information. Tables are the basic storage structure for holding business data. You may want to modify data entered into these tables. You may also want to maintain integrity with the data. Sometimes, you may want to remove tables that are no longer useful. To do this, statements that create, change, and drop schema objects are used. These are called Data Definition Language statements. In this topic, we discuss about Creating and Managing Tables within the database using these statements. Overview: Tables are one of the schema objects which are the basic units of data storage in Oracle Database Express Edition. Tables hold all user-accessible data. Each table contains rows that represent individual data records. Rows are composed of columns that represent the fields of the records. Here, the segments around the core represent how to create, modify, manage and remove tables within the database Create Tables: A Table is a basic structure to hold user data. The purpose of a table is to hold this user information in an organized way. The data within the table is stored in rows and columns. You can create this table using the CREATE TABLE statement Modify Tables: You may need to change the table structure due to any of the following reasons: 1.You omitted a column.or 2.Your column definition needs to be changed.or 3.You need to remove columns. To do this, using the SQL ALTER TABLE statement Manage Constraints: To ensure that the data in your tables satisfies the business rules that your application models, you use constraints. Constraints restrict the values that columns can have. Remove Tables: You can discard a table if you no longer find it useful. The DROP TABLE statement removes the definition of the table from the database. Slide 12: Create Tables: About Creating Tables Moving on, lets take a look about Creating Tables in a bit more detail. To create tables, you can use either the SQL Developer tool Create Table or the DDL statement CREATE TABLE. When creating tables, you must provide: 1. Table name 2. Column name(s) 3. Data types for each column When you create a table, you must specify the SQL data type for each column. The data type of a column determines what values the column can contain. For example, a column of type DATE can contain the value '01-MAY-05', but it cannot contain the numeric value 2 or the character value 'shoe'. Guidelines for Creating Tables: Here are some Guidelines for creating tables: a. Table and column naming rules are 1. It must start with a letter, which is followed by a sequence of letters,numbers,_,#or $ sign 2. It must be 1 to 30 characters long and 3. Must not be an Oracle Server Reserved keyword b. Most commonly used data types are VARCHAR NUMBER DATE TIMESTAMP CHAR You can also set up constraints on your columns to control the data in them. Creating a Copy of Tables: You can create a copy of the existing tables using Oracle SQL Developer Copy tool without affecting the real data. Slide 13: Following are some demonstrations and simulations about the Create Tables topic where some procedural tasks are demonstrated in a step-by-step fashion and you are also invited to perform some steps based on the instructions given to you. Slide 17: Modify Tables In this topic, we discuss about Modifying Tables using the SQL Alter statement. The ALTER TABLE statement is used to: 1.Add a new column 2.Modify an existing column 3.Define a default value for the new column 4.Drop a column and 5.Manage constraints Adding a New Column: You can add a New Column to an existing table. In Oracle Database Express Edition, you can modify tables: Using Oracle SQL Developer or Using the SQL Command Line Utility tools Slide 18: The following is a simulated demonstration on Modifying Tables. Here an existing EMPLOYEES database table can be modified by adding the "BirthDate" column. This simulation allows you to perform step-by-step procedures to add this column using Oracle SQL Developer tool. Slide 20: Manage Constraints Ensure Data Integrity in Tables: In this topic, we discuss about how constraints can be managed in a database table. Data integrity ensures the consistency and correctness of data stored in a database. Such integrity can be enforced by incorporating business rules. Constraints are a set of rules that are enforced on data stored in a table. To ensure that the data in your tables satisfies the business rules that your application models, you can use constraints. Constraints can restrict the values that columns can have. Trying to change the data in a way that violates a constraint causes an error and will undo the change. Trying to add a constraint to a populated table causes an error if existing data violates the constraint. You should use constraints to enforce rules on the data in a table whenever a row is updated, inserted or deleted from that table and to prevent the deletion of a table if there are dependencies from other tables. Constraint Types: The different constraints types are: 1. Not Null, which prevents a value from being null. In the EMPLOYEES table, the column LAST_NAME has the NOT NULL constraint, which enforces the business rule that every employee must have a last name 2. Unique, which prevents multiple rows from having the same value in the same column or combination of columns, but allows some values to be null. In the EMPLOYEES table, the column EMAIL has the UNIQUE constraint, which enforces the business rule that an employee can have no email address, but cannot have the same email address as another employee 3. Primary Key, which is a combination of NOT NULL and UNIQUE. In the EMPLOYEES table, the column EMPLOYEE_ID has the PRIMARY KEY constraint, which enforces the business rule that every employee must have a unique employee identification number. 4. Foreign Key, which requires values in one table to match values in another table. In the EMPLOYEES table, the column JOB_ID has a FOREIGN KEY constraint that references the JOBS table, which enforces the business rule that an employee cannot have a JOB_ID that is not in the JOBS table. 5. Check, which requires that a value satisfy a specified condition. The EMPLOYEES table does not have CHECK constraints. However, suppose that EMPLOYEES needs a new column, EMPLOYEE_AGE, and that every employee must be at least 18. The constraint CHECK (EMPLOYEE_AGE >= 18) enforces the business rule. 6. REF, which further describes the relationship between the column and the object that it references Creating Constraints: Constraints can be enforced at two levels: Column level and Table level A constraint can be created with either of the following statements: CREATE TABLE or ALTER TABLE With the ALTER TABLE statement, you can disable or enable the imposed constraint without dropping it or re-creating it: You disable a constraint by using the DISABLE clause. You can enable a constraint by using the ENABLE clause. Slide 21 : Following is a simulated demonstration on Creating and Managing Constraints. This simulation allows you to perform step-by-step procedures on how business rules can be enforced on the EMPLOYEES table using Oracle SQL Developer tool. Slide 23: Remove Tables Sometimes it becomes necessary to delete a table and all its contents from your schema. DROP TABLE results in the removal of the table definition along with the rows. Tools to Drop Table: There are different ways by which you can drop a table. To drop a table in Oracle Database 11g Express Edition, use either the SQL Developer navigation frame and Drop tool, or alternatively use the DDL statement script DROP TABLE Slide 24: Here is a demonstration of how tables can be removed from the database. Slide 26: Let us now take a brief pause by taking a Quiz Slide 28: Moving on to the next topic in this course, we will be discussing about Creating and Managing other Database Schema Objects Slide 29: Creating and Managing Other Database Objects Oracle Database Express Edition groups related information into logical structures called schemas. The logical structures are called schema objects. When you connect to the database by providing your user name and password, you specify the schema and indicate that you are its owner. In Oracle Database XE, the user name and the name of the schema to which the user connects are the same. Schema objects are logical structures created by users. Apart from tables, there are other objects that are part of a schema. Some objects, such as tables or indexes, hold data. Other objects, such as views or synonyms, consist of a definition only. When you create a database object, you must ensure that you create it in the intended schema. We have already discussed about creating tables which is a schema object. In this topic, we briefly discuss the other commonly used schema objects like views, indexes, sequences and synonyms. Overview: A schema is a collection of database objects. The segments around the core represent the other database schema objects. Views: A view presents the output of a query as a table. In most places that you can use a table, you can use a view. Indexes: Indexes are optional objects that can improve the performance of data retrieval from tables. Sequences: Sequences are schema objects that generate unique sequential values, which are very useful when you need unique primary keys. Synonyms: A synonym is an alias for another schema object. Some reasons to use synonyms are security (for example, to hide the owner and location of an object) and convenience. Slide 30: Creating and Managing Views In this topic we discuss about views and their uses and also the tools that are available to create and manage a view. A view is a logical representation of one or more tables. In essence, a view is a stored query. A view derives its data from the tables on which it is based, called base tables. Base tables can be tables or other views. All operations performed on a view actually affect the base tables. You can use views in most places where tables are used. Views are useful when you need frequent access to information that is stored in several different tables. You can create a view that combines information from several different tables into a single presentation. A view can rely on information from both tables and other views. Views enable you to tailor the presentation of data to different types of users. Views are often used to: Provide an additional level of table security by restricting access to a predetermined set of rows or columns of a table and Hide data complexity For example, a single view can be defined with a join, which is a collection of related columns or rows in multiple tables. However, the view hides the fact that this information actually originates from several tables. A query might also perform extensive calculations with table information. Thus, users can query a view without knowing how to perform a join or calculations. Present the data in a different perspective from that of the base table For example, the columns of a view can be renamed without affecting the tables on which the view is based. Isolate applications from changes in definitions of base tables For example, if the defining query of a view references three columns of a four column table, and a fifth column is added to the table, then the definition of the view is not affected, and all applications using the view are not affected Creating a View: You can create views using either the SQL Developer tool Create View or the DDL statement CREATE VIEW. To change the name of a view, use either the SQL Developer tool Rename or the RENAME statement. To drop a view, use either the SQL Developer navigation frame and Drop tool or the DDL statement DROP VIEW Slide 31: Following is a demonstration about creating a view using the Create View tool in SQL Developer Slide 33: Creating and Managing Indexes In this topic, you learn about Indexes and their uses. What is an Index? An index is an optional structure, associated with a table that can sometimes speed data access. By creating an index on one or more columns of a table, you gain the ability in some cases to retrieve a small set of randomly distributed rows from the table. Indexes are one of many means of reducing disk I/O. Indexes are created on one or more columns of a table and are automatically maintained in the database. When you define a primary key on a table, Oracle Database XE creates a Unique index on the primary key. Creating and Dropping an Index: To create an index, use either the SQL Developer tool Create Index or the DDL statement CREATE INDEX To drop an index, use either the SQL Developer tool Drop or the DDL statement DROP INDEX. To change an index, use either the SQL Developer tool Edit Index or the DDL statements DROP INDEX and CREATE INDEX. Slide 34: Following is a simulation about creating an index using the Create Index Tool Slide 36: Creating and Managing Synonyms: In this topic, you learn what Synonyms are their uses and the different tools that are available to manage Synonyms. You can create a synonym for a table or view, sequence, PL/SQL program unit, user-defined object type, or another synonym. Because a synonym is simply an alias, it requires no storage other than its definition in the data dictionary. Synonyms can simplify SQL statements for database users. Synonyms are also useful for hiding the identity and location of an underlying schema object. If the underlying object must be renamed or moved, then only the synonym must be redefined. Applications based on the synonym continue to work without modification. Some reasons to use synonyms are security (for example, to hide the owner and location of an object) and convenience. Examples of convenience are: ■ Using a short synonym, such as SALES, for a long object name, such as CO.SALES_DATA ■ Using a synonym for a renamed object, instead of changing that object name throughout the applications that use it i.e., if your application uses a table named DEPARTMENTS, and its name changes to DIVISIONS, you can create a DEPARTMENTS synonym for that table and continue to reference it by its original name. Creating and Deleting a Synonym: To create a synonym, you can use either the SQL Developer tool Create Synonym or the DDL statement CREATE SYNONYM. To drop a synonym, use either the SQL Developer navigation frame and Drop tool, or the DDL statement DROP SYNONYM Slide 37: Following is a demonstration about Creating a Synonym using the Create Database Synonym Tool Slide 39: Creating and Managing Sequences In this topic, we discuss about Sequences and the tools available to create and manage them. Sequences are schema objects that generate unique sequential values, which are very useful when you need unique primary keys. When all records of a table must be distinct, you can use a sequence to generate a serial list of unique integers for numeric columns, each of which represents the ID of one record. Sequences are used through the pseudo columns CURRVAL and NEXTVAL, which return the current and next values of the sequence, respectively. After creating a sequence, you must initialize it by using NEXTVAL to get its first value. Only after the sequence is initialized does CURRVAL return its current value. Tip on using a sequence is: When you plan to use a sequence to populate the primary key of a table, give the sequence a name that reflects this purpose. A sequence is a schema object from which multiple users can generate unique integers. A sequence generator provides a highly scalable and well-performing method to generate surrogate keys for a number data type. Creating and Deleting Sequences: You can create a sequence using either the SQL Developer tool Create Sequence or the DDL statement CREATE SEQUENCE. To drop a sequence, use either the SQL Developer navigation frame and Drop tool, or the DDL statement DROP SEQUENCE. Slide 40: Following is a simulation about Creating a Sequence using the Create Database Sequence Tool Slide 42: Let us now take a brief pause by taking a quiz Slide 44: Course Review In this part of the course, we talked about Working with Database Objects which included • Creating Database Administration Account • Creating User Account • Loading Sample Data into the Database • Creating and Managing Database Tables and • Creating and Managing Other Database Schema Objects Well, we have now completed the first part. Please refer to the second part to complete this course. Thank you.