Database-MySQL [3i Infotech Placement]: Sample Questions 8 - 9 of 162

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 8

Question

MCQ▾

Which kind of COMMENT statements are placed within SQL statements?

Choices

Choice (4)

a.

C Style comments (/ ⚹ … ⚹ /)

b.

ANSI SQL style statements (…)

c.

Asterisk (⚹) in column?

d.

All a., b. and c. are correct

Answer

d.

Explanation

Below two syntaxes can create a comment within SQL statement in oracle- making it easier to maintain.

Syntax Using - Symbol

  • Syntax for creating a SQL comment in oracle using - symbol

    -comment goes here

  • A comment started with - symbol and ends with new line in SQL statement.
  • Includes a single line within SQL.

Syntax Using / ⚹ and ⚹ / Symbols

  • Syntax for creating a SQL comment using / ⚹ and ⚹ / symbols is:
    • / ⚹ comment ⚹ /
  • A comment starts with / ⚹ symbol and ends with ⚹ /.
  • This method can span several lines within our SQL.

Question 9

Edit

Describe in Detail

Essay▾

Which system table contains information on constraints on all the created tables?

Explanation

  • USER_CONSTRAINTS
  • TRUNCATE TABLE EMP
  • DELETE FROM EMP

USER_CONSTRAINTS

  • System table contains information on all the tables created.
  • Describes constraint definitions on tables accessible to the current user.

USER_CONSTRAINTS from the oracle data dictionary include the bellow columns:

CONSTRAINT_NAME NOT NULL VARCHAR2 (30)

CONSTRAINT_TYPE VARCHAR2 (1)

TABLE_NAME VARCHAR2 (30)

R_CONSTRAIN_NAME VARCHAR2 (30)

  • Where R_CONSTRAINT_NAME contains the name of the primary key constraint and a foreign key taken as a referenced.
  • Returns only one row for every table constraint in the current database.
  • View returns information about this object for which current user has permission.

TRUNCATE TABLE EMP:

  • Command deletes data from an existing table.
  • DROP TABLE command deletes complete table.

Syntax:

TRUNCATE TABLE table_name;

DELETE FROM EMP:

  • Used to delete rows from a table.
  • Removes one or more records from a table.

Syntax for DELETE:

DELETE FROM table_name [WHERE condition] ;

  • table_name is the table which deleted.
  • WHERE clause in SQL DELETE statement is optional.

Developed by: