Which SQL command correctly adds a new FEES column to the TEACHER table?

2023

Which SQL command correctly adds a new FEES column to the TEACHER table?

Answer: A. ALTER TABLE TEACHER ADD COLUMN FEES FLOAT;ConceptA table schema defines its columns and their data types. SQL changes this structure with a data-definition statement rather than with statements that…

  1. A.

    ALTER TABLE TEACHER ADD COLUMN FEES FLOAT;

  2. B.

    ADD COLUMN FEES FLOAT INTO TEACHER;

  3. C.

    UPDATE TEACHER ADD COLUMN FEES FLOAT;

  4. D.

    INSERT INTO TEACHER ADD COLUMN FEES FLOAT;

Attempted by 2114 students.

Show answer & explanation

Correct answer: A

Concept

A table schema defines its columns and their data types. SQL changes this structure with a data-definition statement rather than with statements that operate on row values.

The general pattern for adding one column is ALTER TABLE <table_name> ADD [COLUMN] <column_name> <data_type>; The word COLUMN is accepted in common dialects such as MySQL and PostgreSQL.

Application

  1. Identify the object being changed: TEACHER is the existing table, so the statement must begin with ALTER TABLE TEACHER.

  2. Describe the structural change: ADD COLUMN introduces FEES, and FLOAT supplies its data type.

  3. Combining the clauses gives ALTER TABLE TEACHER ADD COLUMN FEES FLOAT;

Cross-check and contrast

  • ADD COLUMN FEES FLOAT INTO TEACHER lacks the required ALTER TABLE clause and uses INTO in a position that does not form an add-column statement.

  • UPDATE TEACHER ADD COLUMN FEES FLOAT; starts with UPDATE, whose role is to change values in existing rows.

  • INSERT INTO TEACHER ADD COLUMN FEES FLOAT; starts with INSERT INTO, whose role is to insert rows.

Therefore, the command that adds the column is ALTER TABLE TEACHER ADD COLUMN FEES FLOAT;.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Bpsc

Loading lesson…