Oracle__3. Oracle 1Z0-051 Exam - Table Objects Flashcards
Can a column with a UNIQUE constraint store nulls.
Yes
Can a foreign key contain a null value?
Yes
Is a constraint only enforced by an INSERT operation on the table?
NoA constraint is also enforced by an UPDATE operation on a table
Can a constraint be disabled even if the column contains data?
Yes
Can all constraints be defined at the column level as well as the table level?
NoNULL and NOT NULL are only defined at the column level
Can a constraint prevent deletion of a table?
YesIf there are dependencies. A parent cannot be deleted if a child exists.
Can a table from another schema in the same database be viewed be used in a different schema?
Yesadd prefix to the tablename to access that table from the other schema
Can the ALTER TABLE statement be used to modify a constraint after a table is created?
Yes
What is returned from this statement? CREATE TABLE order (trans_id Number(6) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR, trans_Valid VARCHAR2)
an errorThe varchar2 needs a size value
How many characters can be store in the cust_name field? CREATE TABLE order (trans_id Number(6) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR, trans_Valid VARCHAR2(5))
only 1 character because the size was not identified to the default of one is used.
What is the length of the cust_name field if the value is ‘Ac’? CREATE TABLE order (trans_id Number(6) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR(5), trans_Valid VARCHAR2(5))
5the CHAR field is right-padded with spaces
What is the length of the trans_valid field if the value is ‘Ac’? CREATE TABLE order (trans_id Number(6) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR(5), trans_valid VARCHAR2(5))
2The VARCHAR2 only uses the spaces needed
What is the largest value that can be stored in trans_id? CREATE TABLE order (trans_id Number(2) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR(5), trans_Valid VARCHAR2(5))
99
What is the largest value that can be stored in trans_id? CREATE TABLE order (trans_id Number(2,1) NOT NULL, trans_date DATE NOT NULL, cust_name CHAR(5), trans_valid VARCHAR2(5))
9.9The scale of 1 takes one value from the precision
In defining a numeric field, precision is defined as what?
The total number of decimal digits allowed in the field, either left or right of the decimal.
If defining a numeric field, scale is defined as what?
The total number of digit to the right of the decimal point.
What is the precision of trans_id? CREATE TABLE order (trans_id Number NOT NULL, trans_date DATE NOT NULL, cust_name CHAR(5), trans_valid VARCHAR2(5))
38 digits
What is the maximum size number allowed for a CHAR?
2000
What is the maximum value for a date data type?
12-DEC-9999
What will result after the execution of this statement? CREATE TABLE EMP9$#_A as (empid number(2))
It will create a table name EMP9$#_A with one numeric field named empid.
What will result after the execution of this statement? CREATE TABLE EMP*123 as (empid number(2))
It will fail because there is an arithmetic expression in the table name
What will result after the execution of this statement? CREATE TABLE package as (empid number(2))
It will fail because PACKAGE is a keyword for Oracle
What will result after the execution of this statement? CREATE TABLE ord_details (ord_id NUMBER(2) CONSTRAINT ord_id_pd PRIMARY KEY, ord_date DATE DEFAULT SYSDATE NOT NULL, ord_amount NUMBER(5,2) CONSTRAINT ord_amount_min CHECK (ord_amount >=50), ord_status VARCHAR2(15) CONSTRAINT order_status_chk CHECK(ord_status IN (‘Shipped’,’Not Shipped’)) ord_pay_ode VARCHAR2(15) CONSTRAINT ord_pay_chk CHECK (ord_pay_mode in (‘Check’,’Credit Card’,’Cash’)));
It will execute successfully
What term is used to choose rows from a table?
Selection
What term is used to choose columns from a table?
Projection
Can a column has more than on CHECK constraint?
Yes. A single column can have multiple check constraints and there is no limit.
Can a CHECK constraint reference SYSDATE?
No
Can a DEFAULT column value be SYSDATE?
Yes
Can a column in a table be part of the Primary key and part of a Foreign key?
Yes
What constraint only be defined at the column level?
NOT NULL
What happens to constraints if a table is renamed?
The constraints transfer
What is the syntax to add a default value of 50 for a column named salary in table employees?
ALTER TABLE employeesMODIFY (salary DEFAULT 50)
What happens to when a column constraint NOT NULL is added to a column and there are null values already in the column?
past data is not affected but new nulls are added.
What is the syntax for renaming a column in a table
ALTER TABLE table1 RENAME columnold TO columnnew
What is the syntax of an insert statement with the values clause?
INSERT INTO table1 (field1, field3, field4)VALUES (expression1,expression2,expression3)The number of field names must match the number of values. The data types must also match.
What happens to an index if a DML operation is performed?
The index is updated
What is also created when a primary key is created?
A unique index.Primary keys cannot be duplicated
What is a composite index?
An index with 2 or more columns
What is returned with this statement? ALTER TABLE customers MODIFY cust_name CONSTRAINT cust_name NOT NULL
A constraint is added to the cust_name column that does not allow nulls
What is returned with this statement if the table is populated with records and the cust_name column already has null values? ALTER TABLE customers MODIFY cust_name CONSTRAINT cust_name NOT NULL
Nothing.Past values are not changed, but no new null values can be added to the cust_name column.
What clause can be added to a select statement which will temporary lock records from other users for updating or deleting?
FOR UPDATE
What command can you use to display the structure of a table?
DESCRIBE tablename
What is left after a TRUNCATE table statement?
The table structure is left intact, but all data has been removed
What is a Pseudocolumn?
values generated from commands that behave like a column of a table, but are not actually store in the table.
What DDL is an efficient method of emptying a table?
TRUNCATE
Are delete triggers fired during a TRUNCATE?
No
What could block a TRUNCATE?
if the table is a parent in a referential integrity constraint.
What is the maximum number of characters in a tablename?
30
Besides letters and number what 3 other symbols can be used in a tablename?
- _ (underscore)2. $3. #
By default are tablenames case sensitive?
No
What can be used to make tablesname case sensitive?
“Add double quotes before and after the tablename.”“tablename”””
When an AS subquery is part of a CREATE table besides data types what else is passed to the new table?
NOT NULL contraints
When an AS subquery is part of a CREATE table will the primary key be passed to the new table?
No
What is needed in a create table if one of the columns is an expression?
an Alias to name the column
If a table has 2 columns named ID and NAME what will be inserted into the name column with the following statement? INSERT INTO tablename (ID) VALUES (34);
null
When creating a table with the VARCHAR2 datatype is the size parameter needed?
Yes