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…
- A.
ALTER TABLE TEACHER ADD COLUMN FEES FLOAT; - B.
ADD COLUMN FEES FLOAT INTO TEACHER; - C.
UPDATE TEACHER ADD COLUMN FEES FLOAT; - D.
INSERT INTO TEACHER ADD COLUMN FEES FLOAT;
Attempted by 2117 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
Identify the object being changed:
TEACHERis the existing table, so the statement must begin withALTER TABLE TEACHER.Describe the structural change:
ADD COLUMNintroducesFEES, andFLOATsupplies its data type.Combining the clauses gives
ALTER TABLE TEACHER ADD COLUMN FEES FLOAT;
Cross-check and contrast
ADD COLUMN FEES FLOAT INTO TEACHERlacks the requiredALTER TABLEclause and usesINTOin a position that does not form an add-column statement.UPDATE TEACHER ADD COLUMN FEES FLOAT;starts withUPDATE, whose role is to change values in existing rows.INSERT INTO TEACHER ADD COLUMN FEES FLOAT;starts withINSERT 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.