Which of the following command is used to add attributes to an existin...
The alter table command to add attributes to an existing relation. All tuples in the relation are assigned null as the value for the new attribute. The form of the alter table command is
alter table r add A D;
where r is the name of an existing relation, A is the name of the attribute to be added, and D is the type of the added attribute.
View all questions of this test
Which of the following command is used to add attributes to an existin...
Alter table is the command used to add attributes to an existing relation in a database. This command allows for modifications to be made to the structure of a table, including adding new attributes or columns.
Here is an explanation of each option:
a) Modify table: This is not a valid command in SQL. There is no specific command called "modify table" to add attributes to an existing relation.
b) Drop table: This command is used to delete an entire table from the database. It is not used to add attributes to an existing relation.
c) Set table: This is not a valid command in SQL. There is no specific command called "set table" to add attributes to an existing relation.
d) Alter table: This is the correct command to add attributes to an existing relation. The "alter table" command allows for modifications to be made to the structure of a table. It can be used to add columns, modify column properties, or add constraints to the table.
Example:
Let's say we have a table called "employees" with the following attributes: employee_id, first_name, last_name, and email. If we want to add a new attribute called "phone_number" to this table, we can use the "alter table" command as follows:
```
ALTER TABLE employees
ADD phone_number VARCHAR(20);
```
This command will add a new column called "phone_number" to the "employees" table, with a data type of VARCHAR and a maximum length of 20 characters.
In summary, the correct command to add attributes to an existing relation is the "alter table" command. This command allows for modifications to be made to the structure of a table, including adding new columns.
To make sure you are not studying endlessly, EduRev has designed Railways study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Railways.