Using the sports database containing two relations (TEAM, MATCH_DETAILS) and write the queries for the following: Change the name of the relation TEAM to T_DATA. Also change the attributes TeamID and TeamName to T_ID and T_NAME respectively.
Query 1: ALTER TABLE TEAM RENAME TO T_DATA;
Query 2: ALTER TABLE T_DATA CHANGE TeamID T_ID INT;
Query 3: ALTER TABLE T_DATA CHANGE TeamName T_NAME VARCHAR(20);
Explanation
This question tests the student's knowledge of DDL (Data Definition Language) commands, specifically ALTER TABLE. To rename a relation (table), we use the RENAME TO clause with ALTER TABLE. To rename attributes (columns), we use the CHANGE clause with ALTER TABLE, specifying the old column name, new column name, and the data type. The queries must be executed in sequence - first rename the table, then rename the columns in the newly named table.
Solution Steps
Step 1: Use ALTER TABLE with RENAME TO clause to change table name from TEAM to T_DATA
Step 2: Use ALTER TABLE with CHANGE clause to rename TeamID to T_ID (specifying data type)
Step 3: Use ALTER TABLE with CHANGE clause to rename TeamName to T_NAME (specifying data type)