Skip to main content

Question 13: DDL and Commit

I have updated some tables and before commit if I will give one DDL command means what will happen?

For example
CREATE TABLE test(fldname number(10));
insert into test (fldname) values (10);
insert into test (fldname) values (20);

After that without giving Commit statement, I issued one DDL command
CREATE TABLE test1( sno number(10))
What aobut the previous inserts? Is it committed or not? explain.

Answer:
I checked this and found the following 3 points.

Point No. 1:
If we give a DDL command with syntax error means it will not commit and gives the error. For example the following statement

CREATE TABLE test(fldname number(10), );

note that the comma, gives "invalid identifier.. " error and without committing the INSERT statements.


Point No. 2:
If the given DDL command executes without any error means it will auto commit the INSERT statements.


Point No. 3:

If we give a DDL command without any syntax error and that statement not execute also auto commit the INSERT statements and gives the exception of thee DDL statement. For example the following statement

CREATE TABLE test(fldname number(10) );

gives "name is already used by an existing object" exception after auto commiting the insert statements.

Comments

Popular posts from this blog

Question 8: Aggregate Functions

Examine the description of the STUDENTS table: STD_ID NUMBER(4) COURSE_ID VARCHARD2(10) START_DATE DATE END_DATE DATE Which two aggregate functions are valid on the START_DATE column? (Choose two) A. SUM(start_date) B. AVG(start_date) C. COUNT(start_date) D. AVG(start_date, end_date) E. MIN(start_date) F. MAXIMUM(start_date) Answer: C & E Explanation: It is possible to apply COUNT() and MIN() functions on the column with DATE data type. Incorrect Answers A: Function SUM() cannot be used with DATE data type column. B: Function AVG() cannot be used with DATE data type column. D: Function AVG() cannot be used with DATE data type column, and function AVG() just has one parameter X, not two. It averages all X column values returned by the SELECT statement. F: There is no MAXIMUM() function in Oracle, only MAX() function exists.

21.Oracle - The self documenting dictionary

Oracle - The self documenting dictionary Oracle's Data dictionary is itself self documenting. we can query DICTIONARY AND DICT_COLUMNS views for descriptions of the data dictionary views and their columns. The following query gives the descriptions of all of the data dictionary views. SELECT table_name, comments FROM dictionary ORDER BY table_name; It gives the large amount of output. By using where class we can focus a smaller set of views as like the following query. SELECT table_name, comments FROM dictionary WHERE table_name LIKE '%TABLE%' ORDER BY table_name It returns all views containing the word 'TABLE' Like wise We can query the DICT_COLUMNS view also. It gives the descriptions for the columns for all views. Following query retrieves descriptions for the columns in ALL_TAB_COLUMNS. SELECT column_name, comments FROM dict_columns WHERE table_name = 'ALL_TAB_COLUMNS'; This is a sample one. We can learn lot about oracle through data d...

Question 9: null in where clause

The EMP table contains these columns: LAST NAME VARCHAR2(25) SALARY NUMBER(6,2) DEPARTMENT_ID NUMBER(6) You need to display the employees who have not been assigned to any department. You write the SELECT statement: SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; What is true about this SQL statement? A. The SQL statement displays the desired results. B. The column in the WHERE clause should be changed to display the desired results. C. The operator in the WHERE clause should be changed to display the desired results. D. The WHERE clause should be changed to use an outer join to display the desired results. Answer: C Explanation: The operator in the WHERE clause should be changed to display the desired results. There are times when you want to substitute a value in place of NULL. Oracle provides this functionality with a special function, called NVL(). You can use operation equal with the keywords IS NULL, or you can achieve desired results using NVL() fu...