MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
ALTER TABLE TABELNAME CHANGE
A
NEWCOLNAME NEWDATATYPE
B
NEWCOLNAME OLDDATATYPE
C
OLDCOLNAME NEWCOLNAME NEWDATATYPE
D
OLDCOLNAME NEWCOLNAME OLDDATATYPE
Explanation: 

Detailed explanation-1: -How to Rename a Column with ALTER TABLE. You can rename a column with the below code. You select the table with ALTER TABLE table name and then write which column to rename and what to rename it to with RENAME COLUMN old name TO new name .

Detailed explanation-2: -To rename a column in MySQL the following syntax is used: ALTER TABLE table name RENAME COLUMN old column name TO new column name; This command is used to change the name of a column to a new column name. However, renaming columns this way you run the risk of breaking database dependencies.

Detailed explanation-3: -Since we can’t change data type of a column with values, the approach that I was followed as below, Say the column name you want to change type is ‘A’ and this can be achieved with SQL developer. First sort table data by other column (ex: datetime). Next copy the values of column ‘A’ and paste to excel file.

There is 1 question to complete.