Database Programming Sections 13. Marge Hohly2 13.1.4  1. Which statements are True about the following sequence? The sequence was used to generate numbers.

Slides:



Advertisements
Similar presentations
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Advertisements

9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
11-1 Copyright © Oracle Corporation, All rights reserved. Different type of keys.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
10 Copyright © Oracle Corporation, All rights reserved. Including Constraints.
10 Copyright © 2004, Oracle. All rights reserved. Creating Other Schema Objects.
Managing Schema Objects
Copyright س Oracle Corporation, All rights reserved. 13 Other Database Objects.
Sections 10 – Constraints
4 Copyright © Oracle Corporation, All rights reserved. Displaying Data from Multiple Tables.
Chapter 6 Additional Database Objects
Database Programming Sections 13–Creating, revoking objects privileges.
Objectives After completing this lesson, you should be able to do the following: Categorize the main database objects Review the table structure List.
Dr. Chen, Oracle Database System (Oracle) 1 Chapter 6 Additional Database Objects (up to p.195 and all in the pptx file) Jason C. H. Chen, Ph.D. Professor.
Copyright © 2004, Oracle. All rights reserved. Lecture 3: Creating Other Schema Objects Lecture 3: Creating Other Schema Objects ORACLE.
Oracle Database Administration
12 Copyright © Oracle Corporation, All rights reserved. Other Database Objects.
Other database objects (Sequence). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically used to.
11 Copyright © 2007, Oracle. All rights reserved. Creating Other Schema Objects.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Chapter 5 Sequences.
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.
Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes
10 Copyright © Oracle Corporation, All rights reserved. Including Constraints.
11 Copyright © Oracle Corporation, All rights reserved. Creating Views.
Database Programming Sections 11 & 12 – Creating, and Managing Views, Sequences, Indexes, and Synonymns.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
Database Programming Sections 9 – Constraints. Marge Hohly2 CONSTRAINT TYPES  NOT NULL Constraints  UNIQUE Constraints  PRIMARY KEY Constraints  FOREIGN.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
10 Copyright © Oracle Corporation, All rights reserved. Including Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Managing Constraints. 2 home back first prev next last What Will I Learn? Four different functions that the ALTER statement can perform on constraints.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Schema Objects.
INCLUDING CONSTRAINTS lecture5. Outlines  What are Constraints ?  Constraint Guidelines  Defining Constraint  NOT NULL constraint  Unique constraint.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright © 2004, Oracle. All rights reserved. Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes ORACLE.
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
DDL and Views. Database Objects Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage;
Indexes- What?  Optional structures associated with tables  Provides a quick access path to table data  You can create indexes on one or more columns.
Database Programming Sections 12 – Sequences, Indexes, and Synonymns.
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
Including Constraints. What Are Constraints? Constraints enforce rules at the table level. You can use constraints to do the following: – Enforce rules.
 CONACT UC:  Magnific training   
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
Using DDL Statements to Create and Manage Tables
ITEC 313 Database Programming
Creating Other Schema Objects
Using DDL Statements to Create and Manage Tables
Creating Other Schema Objects
Chapter 5 Sequences.
Managing Objects with Data Dictionary Views
Chapter 2 Views.
Managing Objects with Data Dictionary Views
Using DDL Statements to Create and Manage Tables
Chapter 2 Views.
Index Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23,
Contents Preface I Introduction Lesson Objectives I-2
Using DDL Statements to Create and Manage Tables
IST 318 Database Administration
Including Constraints
Presentation transcript:

Database Programming Sections 13

Marge Hohly  1. Which statements are True about the following sequence? The sequence was used to generate numbers for the DJ on Demand D_CDS table cd_numbers column.  CREATE SEQUENCE cd_numbers_sq INCREMENT BY 15 START WITH 105 MAXVALUE 999 NOMINVALUE CYCLE NOCACHE ____a. The value 165 will not be generated by this sequence. ____b. The value 999 will not be generated by this sequence. ____c. This sequence would be appropriate for PRIMARY KEY values. ____d. If the D_CDS table is deleted, the sequence is also deleted. ____e. If the systems fails sequence values will be lost. ____f. USER_OBJECTS documents this sequence in the data dictionary. ____g. The START WITH value could be changed with an ALTER SEQUENCE.

Marge Hohly  2. In the CREATE TABLE statement shown below, circle the letter of the line(s) that will automatically create an index. a. CREATE TABLE employees( b. employee_id NUMBER(6), c. last_name VARCHAR2(25) NOT NULL, d. VARCHAR2(25) CONSTRAINT emp_ _ukUNIQUE, e. salary NUMBER(8,2), f. commission_pct NUMBER(2,2), g. hire_date DATE NOT NULL, h. CONSTRAINT employee_id_pk PRIMARY KEY(employee_id), i. CONSTRAINT emp_dept_fk FOREIGN KEY(department_id)REFERENCES j. departments(department_id)

Marge Hohly  3. What data dictionary view contains the sequences created by a schema? a. SEQUENCE_VIEW b. USER_SEQUENCES c. SEQUENCE_NAMES d. USER_VIEWS  4. What is the proper syntax for changing the emp_ _index on the column of the employees table? a. CREATE INDEX emp_ _index ON employees ( ); b. ALTER INDEX emp_mail_index FROM employees( ); c. CREATE AND REPLACE INDEX emp_ _index ON employees, COLUMN = ; d. ADD INDEX emp_ _index INTO employees ( ); e. None of the above  Indexes cannot be modified -- instead, DROP and re-create.

Marge Hohly  5. Which data dictionary view is used to view the table name, the index name, and the column name that the index is based on? a. USER_TABLE_INDEXES b. USER_COLUMNS c. USER_IND_COLUMNS d. ALL_INDEXES  6. If the PUBLIC option is not included in the CREATE SYNONYM syntax, which of the following is True? a. Users cannot lengthen object names. b. The DBA does not have access to the synonym. c. The synonym is not accessible to all users. d. All object names must be qualified with PUBLIC.

Marge Hohly  7. What are the last three numbers created by the sequence?  CREATE SEQUENCE sample_seq INCREMENT BY 3 START WITH 6 MAXVALUE 14 NOMINVALUE CYCLE NOCACHE a. 3, 6, 9 b. 6, 9, 12 c. 9, 12, 15 d. 9, 12, 14  8. Which of the following is a good reason to create an index? a. A column has a large number of null values. b. A column has a narrow range of values. c. Most queries are expected to return more than 5% of the rows. d. A table is updated frequently..

Marge Hohly  9. Which of the following constraints can be created at the table level? a. NOT NULL b. FOREIGN KEY c. PRIMARY KEY d. UNIQUE COMPOSITE KEY  10. Which of the following cannot contain a single- row function? a. SELECT b. FROM c. WHERE d. ORDER BY

Marge Hohly  1. The CREATE TABLE AS SELECT syntax can be used to: (choose all that apply) a. create a new table without data based on the structure and column names of an existing table. b. create a new table containing the same structure but different column names as an existing table. c. create a new table containing the structure and data of an existing table. d. create a set of pseudocolumns that query and display part of an existing table.  2. Which identifiers listed below are invalid names for use in the Oracle database? a. a table named: Long_table_name_for_storing_data b. a sequence named: 4generatingUniqueNumbers c. a column named: Primary_Key$Column d. a view named: My&ViewOfData

Marge Hohly9 Guidelines to grant object privileges  To grant privileges on an object, the object must be in your own schema, or you must have been granted the object privileges WITH GRANT OPTION.  An object owner can grant any object privilege on the object to any other user or role of the database.  The owner of an object automatically acquires all object privileges on that object.

Marge Hohly10 Syntax

Marge Hohly  3. SYSDATE and USER are not permitted as references in: a. the values clause of an INSERT statement b. default values for column definitions c. check constraints d. none of the above  4. What will be the column names resulting from the following view definition: CREATE OR REPLACE VIEW Name_Vu (Person_Name, Title, Pay) AS SELECT last_name AS name, job_id position, salary AS compensation FROM employees; a. LAST_NAME, JOB_ID, POSITION b. PERSON_NAME, TITLE, PAY c. NAME, POSITION, COMPENSATION d. none of the above

Marge Hohly  5. To ensure that DML operations performed on a view stay within the domain of the view, use which of the following? a. AS CHECK b. CASCADE c. WITH CHECK OPTION d. CHECK CONSTRAINT  6. A column that will be used to store text data with a size of 4,000 bytes or larger should be defined as which data type? a. varchar2 b. CLOB c. LONG d. CHAR  7. To store time with fractions of seconds, which data type should be used for the column? a. date b. datetime c. timestamp d. interval day to second

Marge Hohly  8. The data type TIMESTAMP WITH TIME ZONE stores: a. The current date, time (including fractions of seconds), and time zone b. The current date, time (without fractions of seconds), and time zone c. The current date, time (including fractions of seconds), and offset from UTC d. The current date, time (including fractions of seconds), and offset from the database time  9. To keep a table from being accessed so it can be dropped when the demand on system resources is lower, use: a. ALTER TABLE modify column b. ALTER TABLE drop column c. ALTER TABLE set unused d. DROP “columnname”FROM songs;

Marge Hohly  10. Comments on tables and columns can be stored for documentation by: a. embedding /* comment */ within the definition of the table. b. using the ALTER TABLE CREATE COMMENT syntax c. using the COMMENT ON TABLE or COMMENT ON COLUMN d. using an UPDATE statement on the USER_COMMENTS table  11. To allow the delete of a parent (primary key) record that has referenced foreign key values, use a. ON DELETE RESTRICT b. ON DELETE SET NULL c. ON DELETE CASCADE d. ON DELETE DELETE

Marge Hohly  12. (True/False) Multicolumn constraints can be defined at the column or table level.  13. (True/False) To give a constraint a name other than SYS_n, precede it with the keyword “CONSTRAINT.”  14. (True/False) NOT NULL constraints are created implicitly when you create a new table using subquery CREATE TABLE AS syntax.

Marge Hohly  15. By default, unique indexes are created when which constraints are enabled? a. PRIMARY KEY b. FOREIGN KEY c. NOT NULL d. CHECK e. UNIQUE  16. Constraints can be: (choose all that apply) a. enabled or disabled b. created or dropped c. changed through “alter constraint” d. viewed in user_constraints  17. (True/False) Like tables, to change a view definition, use the ALTER VIEW syntax.  18. (True/False) To use a view, a person must have security privileges on the tables that the view contains.  19. (True/False) INSERT, UPDATE, and DELETE are never permitted on a view created with the WITH CHECK OPTION clause.

Marge Hohly  20. An inline view is created by placing a subquery in the FROM clause and: a. updating the user_views data dictionary view b. using a GROUP BY clause to group the columns c. enclosing in parentheses the SELECT clause d. giving the subquery an alias  21. Top-n-analysis makes use of a sorted inline view in the FROM clause and (in the outer query): a. a rowid pseudocolumn in the WHERE clause b. the level pseudocolumn in the WHERE clause c. a rownum column in the ORDER BY clause d. ROWNUM in the WHERE clause  22. If you wanted to see the value that you fetched from a sequence named “my_SEQ,” you should reference: a. my_SEQ.last_value b. my_SEQ.nextval c. my_SEQ.currval d. my_SEQ.maxval.

Marge Hohly  23. Sequences can be used to: (choose all that apply) a. ensure that primary key values will be unique and consecutive b. ensure that numbers will be unique even though gaps may exist c. use a range of numbers and optionally cycle through them again d. set a fixed interval for successive numbers  24. The ALTER SEQUENCE syntax can be used to: (choose all that apply) a. change the START WITH of an existing sequence b. reset the MAX VALUE to a lower number than was last used c. change the name of the sequence d. change the interval of the sequence  25. (True/False) Indexes always speed up access to rows in a table.  26. (True/False) To use an index, you must name it in the FROM clause of your query.

Marge Hohly  27. A function-based (or functional) index stores sorted information that contains: a. a rowid and the column(s) key value(s) b. a rowid and a function return based on the column key value c. a rowid and a method that dynamically acts on the key value d. a bitmap for a range of rowids that correspond to a key value  28. A shareable alias for a database object is called a: a. pseudonym b. rowid c. synonym d. view  29. To prevent others from performing DML operations on tables you share in your schema: a. GRANT select b. GRANT view only c. GRANT unused d. GRANT revoke  30. (True/False) The owner of an object automatically acquires all object privileges on objects in his/her schema.