SQL2-ch2 管理綱要物件.

Slides:



Advertisements
Similar presentations
Oracle 10g & 11g for Dev Virtual Columns DML error logging
Advertisements

Refreshing Materialized Views
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)
Oracle Academy Egypt Virtual training week 8 Sections from 7 to 9.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
1 Constraints, Triggers and Active Databases Chapter 9.
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
Constraints We have discussed three types of integrity constraints: primary keys, not null constraints, and unique constraints. CREATE TABLE Movies ( title.
Introduction to Structured Query Language (SQL)
Copyright  Oracle Corporation, All rights reserved. 9 Manipulating Data: INSERT, UPDATE, DELETE.
Introduction to Structured Query Language (SQL)
SQL's Data Definition Language (DDL) – View, Sequence, Index.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
SQL (DDL & DML Commands)
SQL FUNDAMENTALS SQL ( Structured Query Language )
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.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Session 2: SQL (A): Parts 1 and 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
11-1 Copyright  Oracle Corporation, All rights reserved. What Are Constraints? Constraints enforce rules at the table level. Constraints prevent.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
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.
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. 11 Including Constraints.
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.
11 Including Constraints Objectives At the end of this lesson, you will be able to: Describe constraints Create and maintain constraints At the.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
Manipulating Data. Objectives After completing this lesson, you should be able to do the following: Describe each DML statement Insert rows into a table.
9 Manipulating Data. 9-2 Objectives At the end of this lesson, you should be able to: Describe each DML statement Insert rows into a table Update rows.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
Copyright  Oracle Corporation, All rights reserved. 12 Creating Views.
2 Copyright © 2006, Oracle. All rights reserved. Managing Schema Objects.
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.
© 2006 Northgate Information Solutions plc and its associated companies. All rights reserved. Slide 1.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Copyright س Oracle Corporation, All rights reserved. 12 Creating Views.
Oracle 10g Database Administrator: Implementation and Administration Chapter 10 Basic Data Management.
A Guide to SQL, Sixth Edition 1 Chapter 5 Updating Data.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
SQL Statements SELECT INSERTUPDATEDELETECREATEALTERDROPRENAMETRUNCATECOMMITROLLBACKSAVEPOINTGRANTREVOKE Data Retrieval Language (DRL) Data Retrieval Language.
What is the Flashback Database? Improves a database’s availability Useful alternative to traditional restoration methods Contains Flashback logs Archived.
Creating and Managing Tables. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically represents subsets.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
Controlling User Access
Including Constraints
SQL Creating and Managing Tables
Oracle Certified 1z0-047 Exam Questions
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
SQL Creating and Managing Tables
What Is a View? EMPNO ENAME JOB EMP Table EMPVU10 View
SQL Creating and Managing Tables
Managing Schema Objects
(SQL) Manipulating Data
Oracle Data Definition Language (DDL)
IST 318 Database Administration
Presentation transcript:

SQL2-ch2 管理綱要物件

題號 80題:4、15 、 16 、 23 、 26 、 35 、 48 、 56 、 61 、 65 、 78。 140題:38 、 101 、 109 、 122 、 135。

Q4/80 View the Exhibit and examine the structure of the EMP table which is not partitioned and not an index-organized table. Evaluate the following SQL statement: ALTER TABLE emp DROP COLUMN first_name; Which two statements are true regarding the above command? (Choose two.)

A. The FIRST_NAME column would be dropped provided it does not contain any data. B. The FIRST_NAME column would be dropped provided at least one or more columns remain in the table. C. The FIRST_NAME column can be rolled back provided the SET UNUSED option is added to the above SQL statement. D. The FIRST_NAME column can be dropped even if it is part of a composite PRIMARY KEY provided the CASCADE option is used.

Q15/80 Evaluate the following SQL statement: ALTER TABLE hr.emp SET UNUSED (mgr_id); Which statement is true regarding the effect of the above SQL statement?

ALTER TABLE hr.emp SET UNUSED (mgr_id); A. Any synonym existing on the EMP table would have to be re-created. B. Any constraints defined on the MGR_ID column would be removed by the above command. C. Any views created on the EMP table that include the MGR_ID column would have to be dropped and re-created. D. Any index created on the MGR_ID column would continue to exist until the DROP UNUSED COLUMNS command is executed.

Q16/80 EMPDET is an external table containing the columns EMPNO and ENAME. Which command would work in relation to the EMPDET table? A. UPDATE empdet SET ename = 'Amit' WHERE empno = 1234; B. DELETE FROM empdet WHERE ename LIKE 'J%'; C. CREATE VIEW empvu AS SELECT * FROM empdept; D. CREATE INDEX empdet_idx ON empdet(empno);

Q23/80 View the Exhibit and examine the structure of the CUST table. Evaluate the following SQL statements executed in the given order: ALTER TABLE cust ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE INITIALLY DEFERRED; INSERT INTO cust VALUES (1,'RAJ'); --row 1 INSERT INTO cust VALUES (1,'SAM'); --row 2 COMMIT; SET CONSTRAINT cust_id_pk IMMEDIATE; INSERT INTO cust VALUES (1,'LATA'); --row 3 INSERT INTO cust VALUES (2,'KING'); --row 4 Which rows would be made permanent in the CUST table?

A. row 4 only B. rows 2 and 4 C. rows 3 and 4 D. rows 1 and 4 INSERT INTO cust VALUES (1,'RAJ'); --row 1 INSERT INTO cust VALUES (1,'SAM'); --row 2 COMMIT; SET CONSTRAINT cust_id_pk IMMEDIATE; INSERT INTO cust VALUES (1,'LATA'); --row 3 INSERT INTO cust VALUES (2,'KING'); --row 4 A. row 4 only B. rows 2 and 4 C. rows 3 and 4 D. rows 1 and 4

Q26/80 Which statement is true regarding external tables? A. The default REJECT LIMIT for external tables is UNLIMITED.(P2-34) 預設為0 B. The data and metadata for an external table are stored outside the database. C. ORACLE_LOADER and ORACLE_DATAPUMP have exactly the same functionality when used with an external table. D. The CREATE TABLE AS SELECT statement can be used to unload data into regular table in the database from an external table.

Q35/80 Evaluate the following SQL statements in the given order: DROP TABLE dept; CREATE TABLE dept (deptno NUMBER(3) PRIMARY KEY, deptname VARCHAR2(10)); FLASHBACK TABLE dept TO BEFORE DROP; Which statement is true regarding the above FLASHBACK operation?

A. It recovers only the first DEPT table. B A. It recovers only the first DEPT table. B. It recovers only the second DEPT table. C. It does not recover any of the tables because FLASHBACK is not possible in this case. D. It recovers both the tables but the names would be changed to the ones assigned in the RECYCLEBIN.

Q48/80 Evaluate the following CREATE TABLE command: CREATE TABLE order_item ( order_id NUMBER(3), item_id NUMBER(2), qty NUMBER(4), CONSTRAINT ord_itm_id_pk PRIMARY KEY (order_id,item_id) USING INDEX (CREATE INDEX ord_itm_idx ON order_item(order_id,item_id))); Which statement is true regarding the above SQL statement?

A. It would execute successfully and only ORD_ITM_IDX index would be created. B. It would give an error because the USING INDEX clause cannot be used on a composite primary key. C. It would execute successfully and two indexes ORD_ITM_IDX and ORD_ITM_ID_PK would be created. D. It would give an error because the USING INDEX clause is not permitted in the CREATE TABLE command.

Q56/80 Which mandatory clause has to be added to the following statement to successfully create an external table called EMPDET? CREATE TABLE empdet ( empno CHAR(2), ename CHAR(5), deptno NUMBER(4)) ORGANIZATION EXTERNAL(LOCATION ('emp.dat')); A. TYPE B. REJECT LIMIT C. DEFAULT DIRECTORY D. ACCESS PARAMETERS

Q61/80 Evaluate the following SQL statements that are issued in the given order: CREATE TABLE emp (emp_no NUMBER(2) CONSTRAINT emp_emp_no_pk PRIMARY KEY, ename VARCHAR2(15), salary NUMBER(8,2), mgr_no NUMBER(2) CONSTRAINT emp_mgr_fk REFERENCES emp); ALTER TABLE emp DISABLE CONSTRAINT emp_emp_no_pk CASCADE; ENABLE CONSTRAINT emp_emp_no_pk; What would be the status of the foreign key EMP_MGR_FK?

A. It would be automatically enabled and deferred. B A. It would be automatically enabled and deferred. B. It would be automatically enabled and immediate. C. It would remain disabled and has to be enabled manually using the ALTER TABLE command. D. It would remain disabled and can be enabled only by dropping the foreign key constraint and re-creating it.

Q65/80 Which statement is true regarding Flashback Version Query? A. It returns versions of rows only within a transaction. B. It can be used in subqueries contained only in a SELECT statement. C. It will return an error if the undo retention(保留) time is less than the lower bound time or SCN specified. D. It retrieves all versions including the deleted as well as subsequently reinserted versions of the rows.

Q78/80 View the Exhibit and examine the structure of the EMP table belonging to the user SCOTT. The EMP table contains the details of all the current employees in your organization. EMPNO is the PRIMARY KEY. User SCOTT has created an ENAME_IDX index on the ENAME column and an EMP_VW view that displays the ENAME and SALARY columns. The recyclebin is enabled in the database. SCOTT executes the following command: SQL> DROP TABLE emp; Which details would be stored in the recyclebin? (Choose all that apply)

A. EMP_VW B. ENAME_IDX C. The PRIMARY KEY constraint D A. EMP_VW B. ENAME_IDX C. The PRIMARY KEY constraint D. Only the structure of the EMP table E. Structure and data of the EMP table

Q38/140 View the Exhibit and examine the data in EMP and DEPT tables. In the DEPT table, DEPTNO is the PRIMARY KEY. In the EMP table, EMPNO is the PRIMARY KEY and DEPTNO is the FOREIGN KEY referencing the DEPTNO column in the DEPT table. What would be the outcome of the following statements executed in the given sequence? DROP TABLE emp; FLASHBACK TABLE emp TO BEFORE DROP; INSERT INTO emp VALUES (2, SCOTT, 10); INSERT INTO emp VALUES (3, KING, 55);

A. Both the INSERT statements would fail because all constraints are automatically retrieved when the table is flashed back. B. Both the INSERT statements would succeed because none of the constraints on the table are automatically retrieved when the table is flashed back. C. Only the first INSERT statement would succeed because all the constraints except the primary key constraint are automatically retrieved after a table is flashed back. D. Only the second INSERT statement would succeed because all the constraints except referential integrity constraints that reference other tables are retrieved automatically after the table is flashed back.

Q101/140 View the Exhibit and examine the ORDERS table. The ORDERS table contains data and all orders have been assigned a customer ID. Which statement would add a NOT NULL constraint to the CUSTOMER_ID column? A. ALTER TABLE orders ADD CONSTRAINT orders_cust_id_nn NOT NULL (customer_id); B. ALTER TABLE orders MODIFY customer_id CONSTRAINT orders_cust_id_nn NOT NULL; (P2-10) C. ALTER TABLE orders MODIFY CONSTRAINT orders_cust_id_nn NOT NULL (customer_id); D. ALTER TABLE orders ADD customer_id NUMBER(6) CONSTRAINT orders_cust_id_nn NOT NULL;

Q109/140 The first DROP operation is performed on PRODUCTS table using the following command: DROP TABLE products PURGE; Then you performed the FLASHBACK operation by using the following command: FLASHBACK TABLE products TO BEFORE DROP; Which statement describes the outcome of the FLASHBACK command?

A. It recovers only the table structure. B A. It recovers only the table structure. B. It recovers the table structure, data, and the indexes. C. It recovers the table structure and data but not the related indexes. D. It is not possible to recover the table structure, data, or the related indexes.

Q122/140 View the Exhibit and examine the data in the PRODUCTS table. Which statement would add a column called PRICE, which cannot contain NULL?

A. ALTER TABLE products ADD price NUMBER(8,2) NOT NULL; B A. ALTER TABLE products ADD price NUMBER(8,2) NOT NULL; B. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT NOT NULL; C. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT 0 NOT NULL; D. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT CONSTRAINT p_nn NOT NULL;

Q135/140 Evaluate the following ALTER TABLE statement: ALTER TABLE orders SET UNUSED (order_date); Which statement is true? A. The DESCRIBE command would still display the ORDER_DATE column. B. ROLLBACK can be used to get back the ORDER_DATE column in the ORDERS table. C. The ORDER_DATE column should be empty for the ALTER TABLE command to execute successfully. D. After executing the ALTER TABLE command, you can add a new column called ORDER_DATE to the ORDERS table.