Machine-translated by Google. Questions are authored in English.
Top

Introduction to SQL Questions and Answers

101.

Which one of the following is used to define the structure of the relation ,deleting relations and relating schemas ?

Answer: B

Correct answer: DDL(Data Definition Langauge)

Defining a relation's structure, deleting relations and relating schemas are all structural operations, and they belong to the Data Definition Language - CREATE, ALTER and DROP.

DML works on the data those structures hold. A query is one DML statement rather than a language, and a relational schema is the description DDL produces, not the means of producing it. A practical consequence of the split: in most engines DDL commits implicitly and cannot be rolled back.

Please log in or register to report this question.

102.

Which one of the following provides the ability to query information from the database and to insert tuples into, delete tuples from, and modify tuples in the database ?

Answer: A

Correct answer: DML(Data Manipulation Langauge)

Querying, inserting, deleting and modifying tuples are exactly the operations of the Data Manipulation Language: SELECT, INSERT, DELETE and UPDATE.

DDL by contrast defines the structures those tuples live in. Note that the query language is a part of DML rather than a separate thing, which is why "Query" as an option is too narrow - it names one of the four capabilities the question lists. A relational schema is a description, not a language.

Please log in or register to report this question.

103.

Create table employee (name varchar ,id integer) What type of statement is this ?

Answer: B

Correct answer: DDL

CREATE TABLE defines a new relation, naming its attributes and their domains, so it is a Data Definition Language statement.

The test is what the statement acts on: DDL changes the structure of the database, DML changes the data within it. Nothing is stored by this statement - it produces an empty table awaiting rows. The declaration name varchar is worth noticing as incomplete in standard SQL, which requires a length as varchar(n).

Please log in or register to report this question.

104.

Select * from employee What type of statement is this?

Answer: A

Correct answer: DML

SELECT reads data from a relation without altering any structure, so it is a Data Manipulation Language statement.

DML has four members - SELECT, INSERT, UPDATE and DELETE - and SELECT is the only one that does not modify anything, which is why some texts place it in a query sublanguage of its own. A view would be created by a DDL statement, and an integrity constraint is a rule declared as part of a table definition.

Please log in or register to report this question.

105.

The basic data type char(n) is a _____ length character string and varchar(n) is _____ length character.

Answer: C

Correct answer: Fixed, variable

char(n) always occupies \( n \) characters: a shorter value is padded with trailing spaces to fill the width. varchar(n) stores only the characters actually supplied, up to a maximum of \( n \).

The trade is space against predictability. char wastes space on short values but has a fixed offset, which can make row access marginally faster; varchar stores just what is needed at the cost of a length prefix. The practical rule is char for genuinely fixed-width codes and varchar for anything that varies.

Please log in or register to report this question.

106.

An attribute A of datatype varchar(20) has the value “Avi” . The attribute B of datatype char(20) has value ”Reed” .Here attribute A has ____ spaces and attribute B has ____ spaces .

Answer: A

Correct answer: 3, 20

The attributes are asked for as stored, not as supplied. A is varchar(20) holding "Avi", and a varying-length type stores only the characters given, so it occupies 3.

B is char(20) holding "Reed". A fixed-length type pads to its full width with trailing spaces, so it occupies 20 whatever the value's length. That padding has a consequence beyond storage: comparisons and concatenations may carry the trailing spaces, which is why char is reserved for values that really are of fixed width.

Please log in or register to report this question.

107.

To remove a relation from an SQL database, we use the ______ command.

Answer: D

Correct answer: Drop table

DROP TABLE removes the relation entirely - its rows, its definition, its indexes and its constraints - leaving no object of that name.

DELETE is the near-miss and the distinction is important: it removes rows but keeps the table, so an empty relation remains ready for new data. DROP is a DDL statement and DELETE a DML one. Purge and Remove are not standard SQL for this purpose.

Please log in or register to report this question.

108.

Delete from r; r - relation This command performs which of the following action ?

Answer: B

Correct answer: Clear relation entries

DELETE FROM r with no WHERE clause removes every tuple in the relation, leaving the relation itself in place - defined, empty, and ready for new rows.

That is the precise sense in which the entries are cleared rather than the relation removed: DROP TABLE r would be needed for the latter. Nor are fields affected, since DELETE works on whole rows and never on the column structure. TRUNCATE TABLE achieves the same emptying more quickly, without logging each row.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Introduction to SQL Questions and Answers || Introduction to SQL MCQ Questions and Answers || Introduction to SQL GK Questions and Answers || Introduction to SQL GK MCQ Questions || Introduction to SQL Multiple Choice Questions and Answers || Introduction to SQL GK || GK on Introduction to SQL || Database Questions and Answers || Database MCQ Questions and Answers || Database GK Questions and Answers || GK on Database