1.

Ms. Archana, a class XI student has just started learning MySQL. Help her in understanding the basic difference between Alter and Update command with suitable example.Also suggest her suitable command for the following purpose:(i) To display the list of the databases already existing in MySQL.(ii) To use the database named City.(iii) To remove the pre-existing database named Clients.(iv) To remove all the records of the table named “Club” at one go along with its structure permanently.

Answer»
ALTERUPDATE
It‟s a DDL command.It‟s a DML command.
  • It can be used for the following purpose:
  • To add a new column.
  • To remove an existing column.
  • To modify a column.
  • To add/remove a constraint.
It‟s used to modify the records of the table.

Example:
If a table named emp already exists with 
following columns:

EmpnoNameDept

To add an address column, we may use following command:

Alter Table emp add address varchar(20);

Example:
To modify the address to Noida from “New Delhi”, we may use the following command :
Update emp set address= “Noida” where city= “New Delhi”;

suitable command:

(i) Show Databases

(ii) Use City

(iii) Drop Database Clients

(iv) Drop table Club



Discussion

No Comment Found

Related InterviewSolutions