Oracle__3. Oracle 1Z0-051 Exam - Table Objects Flashcards

1
Q

Can a column with a UNIQUE constraint store nulls.

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can a foreign key contain a null value?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is a constraint only enforced by an INSERT operation on the table?

A

NoA constraint is also enforced by an UPDATE operation on a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can a constraint be disabled even if the column contains data?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can all constraints be defined at the column level as well as the table level?

A

NoNULL and NOT NULL are only defined at the column level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can a constraint prevent deletion of a table?

A

YesIf there are dependencies. A parent cannot be deleted if a child exists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can a table from another schema in the same database be viewed be used in a different schema?

A

Yesadd prefix to the tablename to access that table from the other schema

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can the ALTER TABLE statement be used to modify a constraint after a table is created?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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)

A

an errorThe varchar2 needs a size value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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))

A

only 1 character because the size was not identified to the default of one is used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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))

A

5the CHAR field is right-padded with spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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))

A

2The VARCHAR2 only uses the spaces needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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))

A

99

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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))

A

9.9The scale of 1 takes one value from the precision

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In defining a numeric field, precision is defined as what?

A

The total number of decimal digits allowed in the field, either left or right of the decimal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If defining a numeric field, scale is defined as what?

A

The total number of digit to the right of the decimal point.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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))

A

38 digits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the maximum size number allowed for a CHAR?

A

2000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the maximum value for a date data type?

A

12-DEC-9999

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What will result after the execution of this statement? CREATE TABLE EMP9$#_A as (empid number(2))

A

It will create a table name EMP9$#_A with one numeric field named empid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What will result after the execution of this statement? CREATE TABLE EMP*123 as (empid number(2))

A

It will fail because there is an arithmetic expression in the table name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What will result after the execution of this statement? CREATE TABLE package as (empid number(2))

A

It will fail because PACKAGE is a keyword for Oracle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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’)));

A

It will execute successfully

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What term is used to choose rows from a table?

A

Selection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What term is used to choose columns from a table?
Projection
26
Can a column has more than on CHECK constraint?
Yes. A single column can have multiple check constraints and there is no limit.
27
Can a CHECK constraint reference SYSDATE?
No
28
Can a DEFAULT column value be SYSDATE?
Yes
29
Can a column in a table be part of the Primary key and part of a Foreign key?
Yes
30
What constraint only be defined at the column level?
NOT NULL
31
What happens to constraints if a table is renamed?
The constraints transfer
32
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)
33
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.
34
What is the syntax for renaming a column in a table
ALTER TABLE table1 RENAME columnold TO columnnew
35
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.
36
What happens to an index if a DML operation is performed?
The index is updated
37
What is also created when a primary key is created?
A unique index.Primary keys cannot be duplicated
38
What is a composite index?
An index with 2 or more columns
39
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
40
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.
41
What clause can be added to a select statement which will temporary lock records from other users for updating or deleting?
FOR UPDATE
42
What command can you use to display the structure of a table?
DESCRIBE tablename
43
What is left after a TRUNCATE table statement?
The table structure is left intact, but all data has been removed
44
What is a Pseudocolumn?
values generated from commands that behave like a column of a table, but are not actually store in the table.
45
What DDL is an efficient method of emptying a table?
TRUNCATE
46
Are delete triggers fired during a TRUNCATE?
No
47
What could block a TRUNCATE?
if the table is a parent in a referential integrity constraint.
48
What is the maximum number of characters in a tablename?
30
49
Besides letters and number what 3 other symbols can be used in a tablename?
1. _ (underscore)2. $3. #
50
By default are tablenames case sensitive?
No
51
What can be used to make tablesname case sensitive?
"Add double quotes before and after the tablename.""tablename"""
52
When an AS subquery is part of a CREATE table besides data types what else is passed to the new table?
NOT NULL contraints
53
When an AS subquery is part of a CREATE table will the primary key be passed to the new table?
No
54
What is needed in a create table if one of the columns is an expression?
an Alias to name the column
55
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
56
When creating a table with the VARCHAR2 datatype is the size parameter needed?
Yes
57
When creating a table with the CHAR datatype is the size parameter needed?
No. The default will be 1 character
58
What data type is not copied when using the subquery in a create table?
LONG
59
What datatype cannot be used in a GROUP BY or an ORDER BY clause?
LONG
60
How many column can have the data type of LONG in a single table?
Only one column of data type LONG can be in any table.
61
Can any constraints be defined in a LONG column?
No
62
List 5 common data integrity constraints?
1. NOT NULL2. UNIQUE3. PRIMARY KEY4. FOREIGN KEY5. CHECK
63
If you do not name your constraint Oracle will automatically create a number with a prefix, what is the prefix?
SYS_CExample: SYS_C1234556
64
Functionally are table-level constraints and column-level constraints the same?
yes
65
What is the syntax of a primary key defined at the column level?
columnname datatype CONTRAINT constraintname PRIMARY KEY
66
What is the syntax of a primary key defined at the table level?
After the last column name is definedCONSTRAINT constraintname PRIMARY KEY (columnname)
67
What constraint type is used to establish and enforce referential integrity?
FOREIGN KEY
68
Can a primary key include more that one column?
Yes
69
At what level must the primary key be defined if it includes more than one column?
table level
70
What happens if you forget to name a CONSTRAINT?
Oracle will automatically assign it a Number with the prefix SYS_C
71
What other constraint is automatically created on the columns in a primary key?
UNIQUE Constraint
72
Can any of the field in a primary key contain a null?
No
73
Are foreign key logical or physical pointers?
logical
74
What is the syntax of creating a foreign key?
CONSTRAINT constraintname FOREIGN KEY (columnname) REFERENCES tablename(columnname)
75
Can a foreign key be defined at the column level or at the table level?
Yes, but only if the foreign key is only one column
76
When must a Primary key be defined at the table level?
When more than 1 column name is part of the primary key.
77
What 2 options can be added to the parent table so that a row can be deleted even if it is referenced in a child table?
1. ON DELETE CASCADE2. ON DELETE SET NULL
78
Can a check constraint be added at the column level or at the table level?
Both, a check constraint can be added at either the column level or table level
79
Can a single column have more than one CHECK constraint?
yes
80
How is the UNIQUE constraint enforced?
By created an index on the unique key column or columns
81
What keyword can be added to a table to make it read only?
READ ONLY
82
What is the keyword to remove the READ ONLY on a table?
READ WRITE
83
What command will remove a table and all its contents?
DROP
84
What is also lost when a table is dropped?
Indexes and constraints
85
What keyword is added to the DROP command to allow the space to be release back to the tablespace for use by another object?
PURGE
86
What are the 2 types of indexes?
1. Unique2. nonunique
87
What can happen to a UPDATE statement on a table when indexes are created?
The update performs slower
88
What can improve performance for a select statement?
creating indexes on the column names used in the where clause
89
What can improve performance if a column has a large number of null values?
create an index
90
What can improve performance on a column if the column contains a wide range of values?
create an index
91
If a table is large and most queries return only 2% to 4% of the rows, what can be done to improve performance?
create an index
92
If a column is references as part of an expression will an INDEX improve performance?
No
93
What is the syntax to remove an index?
DROP INDEX indexname
94
What is the maximum significant digits for a number data type?
38
95
What is the maximum number of characters for a VARCHAR2?
4000
96
What is a SELECTION?
choose rows from a table
97
What is a PROJECTION?
choose column from a table
98
How can you temporary disable a constraint without removing it from the table?
ALTER TABLE table1 DISABLE CONSTRAINT constraintname
99
What is stored in a data type of CHAR(5) when a value of 'AB' is inserted?
The CHAR(5) is right padded with spaces
100
The CLOB data type can have up to how many characters?
4 GB
101
What else is created when you create a UNIQUE CONSTRAINT on a column?
A unique index is also created.But creating a unique index does not create a unique constraint
102
What is the difference between a Unique Index and a Unique Constraint?
a unique index cannot be seen by the user. A unique constraint requires the values to be unique in the column.
103
Can SYSDATE be used as a default?
YES
104
Can SYSDATE be used as a check constraint?
No
105
What is automatically created when a PRIMARY KEY or a UNIQUE constraint is created?
a Unique key
106
What is the difference between a unique constraint and a unique index?
a unique constraint requires the values to be unique.unique indexes are not seen by the user
107
What condition must exist before a primary key can be added to a table that already is populated with data?
No duplicate in the columns to be defined in the primary key.
108
Can more than one index be created on the same column?
No. Only 1 single column index can be created on a column, but the column can be part of several multi-column indexes?
109
Can a table have more than one foreign key?
Yes
110
What is the syntax to create a primary key on Student_ID after the table students has been created?
ALTER TABLE students ADD CONSTRAINT stud_pk PRIMARY KEY (student_id)
111
What is the name of the system view which displays the column associated with constraints on a table owned by the user?
USER_CONS_COLUMNS
112
What is the correct syntax for a foreign key to the student_id column on the student table
CONSTRAINT student_pd FOREIGN KEY (student_id) REFERENCES students(student_id)
113
What is the syntax to remove a column job1 from Table1?
ALTER TABLE Table1 DROP COLUMN (job1);
114
What is the syntax to rename column job1 to job2 in table1?
ALTER TABLE table1 RENAME job1 TO job2
115
What is the syntax to add column job1 to table1?
ALTER TABLE table1 ADD (job1 VARCHAR2(20));VARCHAR2(20) is just an example
116
What is the syntax to change the data type of column job1 in table1?
ALTER TABLE table1 MODIFY (job1 VARCHAR2(10) );VARCHAR2(20) is just an example
117
What is the syntax to change table table1 to Read only?
ALTER TABLE table1 READ ONLY;
118
What is the syntax for adding a constraint to table1 on column job1 where the value must be equal to or greater than 2000?
ALTER TABLE table1 ADD CONSTRAINT constraint_name CHECK (job1 >= 2000);
119
What is the syntax for modifying a constraint to table1 on job1.
ALTER TABLE table1 MODIFY (job1 CONSTRAINT constraint_name NOT NULL);
120
What is the syntax to remove a constraint constraint_name from table1?
ALTER TABLE table1 DROP CONSTRAINT constraint_name ;
121
What is the range for the scale for the number data type?
-84 to 127
122
What is the syntax for creating table2 data structure without the data from table1?
CREATE TABLE table2 AS SELECT * FROM table1 WHERE 1=2;
123
What will be the result if 12345.12345 is enter into a data type of NUMBER(6,2)?
errorThe range of the integer part is only from -9999 to 9999.
124
What will be the result is 123456 is enter into a data type of NUMBER(6,2)?
error
125
What will be the result is 123456 is enter into a data type of NUMBER(5,-2)?
1234600 Rounded to the nearest hundred.
126
What will be the result is 123456789 is enter into a data type of NUMBER(5,-2)?
Error. Because it is outside the range; can have only five digits, excluding the four trailing zeros.
127
What will be the result if 0.1 is enter into a data type of NUMBER(4,5)?
errorRequires a zero after the decimal point (5 - 4 = 1).
128
What will be the result if 12345.58 is enter into a data type of NUMBER(*,1)?
The use of * in the precision specifies the default limit (38).
129
Literals are values that represent a fixed values (constant). What are the 4 types of literals?
Text (or character) Numeric (integer and number) Datetime Interval
130
What is the default format for internally stored date?
numeric
131
What is not needed in this statement? CREATE TABLE ord_details (ord_no NUMBER(2), item_no NUMBER(3), ord_date DATE DEFAULT NOT NULL, CONSTRAINT Ord_non UNIQUE (ord_no), CONSTRAINT Ord_pk PRIMARY KEY (ord_no));
The Unique constraint is not need because it is automatically created with the primary key constraint.
132
A unique index will get created when either of 2 things are created. What are they?
A unique index gets created with either a Primary key or a Unique key is created on a table.
133
Can a Primary key contain a null?
No.
134
Change the syntax so the Ord_no field will have no duplicate values; CREATE TABLE ord_details (ord_no NUMBER(2), item_no NUMBER(3), ord_date DATE DEFAULT NOT NULL)
Add keyword UNIQUECREATE TABLE ord_details(ord_no NUMBER(2) UNIQUE,item_no NUMBER(3),ord_date DATE DEFAULT NOT NULL)
135
What is true about group functions on columns and null values?
Group functions on columns ignore NULL values
136
Can a Unique constraint have a null value?
No.Unique constraints and Primary keys do not allow null values.
137
List 5 types of constraints.
NOT NULLUNIQUEPRIMARY KEYFOREIGN KEYCHECK
138
Is the following statement true? A table can have only one primary key but multiple foreign keys.
Yes
139
Will this statement create an error? CREATE TABLE products ( prod_id Number, prod_name CHAR(30), CONSTRAINT prod_name NOT NULL)
Yes.You cannot create a NOT NULL constraint at the table level.
140
Will this clause cause an error? WHERE inv_no BETWEEN '101' AND '102'
No.The characters are implicitly converted to numeric
141
Will this statement create an error? SELECT item_no, AVG(qty) FROM ord_items HAVING AVG(qty) > MIN(qty) * 2 GROUP BY item_no
No.HAVING and GROUP BY are interchangeable.
142
What is wrong with this statement? CREATE TABLE ord_details (ord_no NUMBER(2), item_no NUMBER(2), ord_Date DATE DEFAULT NOT NULL, CONSTRAINT ord_uq UNIQUE(ord_no), CONSTRAINT ord_pk PRIMARY KEY(ord_no));
The PRIMARY_KEY make each row unique so the unique is not needed, plus UNIQUE allow nulls and PRIMARY KEY does not