Alterations on the table in SQL

Alterations on table in SQL

Right now, will find out about the changes on the tables in SQL.

A Table is a lot of fields which characterizes the manner in which the records will store in the database and furthermore a lot more things. These things are helpful, yet at times likewise prohibitive.

Consequently, the need to change or adjust the principles or fields with a SQL inquiry gets prominent. For example, in the event that you need to include another field called status in the effectively made table all you should do is this:

 ALTER TABLE table_name ADD status varchar(45);

Presently, it will make another field with a name called status. The Field will be blanked for all the spared records in the table.

Presently, we can likewise drop tables, change the information kind of the fields or alter the segment in some other manner. This is likely exceptionally helpful to know the fundamental idea of both of these ideas. We should drop a segment name from the table with a SQL question:

 ALTER TABLE table_name DROP COLUMN status;

This will drop the section from the table and furthermore the fields from the effectively spared records in the table. Likewise, we can likewise drop the table from the database.

Sham information:

Alterations on the table in SQL

Syntax (ADD column)

ALTER TABLE table_name ADD column_name datatype;

Syntax (DROP column)

ALTER TABLE table_name DROP COLUMN column_name;

Syntax (MODIFY column)

ALTER TABLE table_name MODIFY COLUMN column_name datatype;

Example (DROP primary key)

ALTER TABLE 'JustTechReview'.'employees' DROP PRIMARY KEY;

Example (ADD column)

ALTER TABLE ' JustTechReview '.'employees' ADD BONUS int;
Alterations on the table in SQL

Example (DROP column)

ALTER TABLE 'JustTechReview'.'employees' DROP BONUS;
Alterations on the table in SQL

Recent Posts

error: Alert: Content is protected!!