Home Sql Mysql-alter Mysql Alter Command
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Mysql Alter Command

Advertisement
Mysql Alter Command define the list of Command used for removing 'Primary key','Unique index','Delete Column','Change column' etc.

Mysql Alter Command

     

Mysql Alter Command define the list of Command used for removing 'Primary key','Unique index','Delete Column','Change column' etc.

Understand with Example

The Tutorial illustrate an example from 'Mysql Alter Command'. To understand this example  we use Alter keyword that redefine the table 'tablename' and Drop primary key is used  to remove/delete the primary key in a table.  

SYNTAX:

 

 

 

For removing primary key:-

ALTER TABLE tablename DROP PRIMARY KEY;

For removing a Unique index:

The Alter table is used to modify the table 'table name' and remove the index 'index_name' from the existing 'tablename'. 

ALTER TABLE tablename DROP INDEX index_name;

Adding a primary key :

The Alter Table is used to modify table 'tablename' and add a primary key to the column 'index_column'.

ALTER TABLE tablename ADD PRIMARY KEY (index_columns);

Delete a column:

The given below Syntax uses 'Alter' table is used to redefine the table 'tablename' and drop query is used to delete the column name.

ALTER TABLE table name drop column column name;

Add a new column to db:

The below Query is used to modify the table 'tablename' and add a column 'columnname'.

ALTER TABLE tablename ADD Column columnname type;

Change column name:

The below Alter Table is used to modify the tablename and change the column name. 

ALTER TABLE tablename change oldcolumnname newcolumnname type;

Make a unique column:

The given below Query 'Alter Table' is used to modify the table  and add a unique column name.

ALTER TABLE tablename add unique columnname;

Delete unique from table:

The given below Query is used to modify the table and delete the column name from index.

ALTER TABLE tablename drop index columnname;

Alter a column size:

The Alter Table is used to modify the table and alter the size of column.

ALTER TABLE table name modify column name type;

Renaming a Table:

The Alter Table is used to modify the table and change the table name.

ALTER TABLE table name RENAME  To tablename;
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 13, 2009

Related Tutorials

Ask Questions?    Discuss: Mysql Alter Command  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
manish kumar
March 30, 2012
Nice work

sir, i want to say that this site really works very nice for the student point of view. thankssssssssss
neha jaiswal
April 2, 2012
thnks............???

sir, its a nice approach by you that we are getting benefit from it so very very thanks to you and you team member.
DMCA.com