101k views
2 votes
Write SQL statements for the following: 1. 2. 3. Change the column Z of a table XYZ to now acceptdefault value 9999 Delete a table from the database Delete column Z from the table XYZ

1 Answer

5 votes

Answer:

1.In the first query the column Z of table xyz wil change and set to its default value so we use alter command .

Syntax :ALTER TABLE TABLENAME ALTER COLUMN NAME SET DEFAULT VALUE

So SQL query is :

ALTER TABLE XYZ ALTER Z SET DEFAULT 9999 ;

This query will Change the column Z of a table XYZ to acceptdefault value 9999 .

2.In the second query we delete a table from database so we use DROP command .

Syntax :DROP TABLE TABLENAME;

So SQL query is :DROP TABLE XYZ;

This query will delete the table from database.

3.In the last query we have to change the column Z from table again we use alter command .

Syntax:ALTER TABLE TABLENAME DROP COLUMN COLUMNNAME ;

So SQL query is :

ALTER TABLE XYZ DROP COLUMN Z;

This query will delete column Z from the table XYZ.

User Stackoverblown
by
5.0k points