Add Column:
import java.sql.*;
class Alter_Add
{
public static void main ( String args[] )
{
try
{
Class.forName ( "com.mysql.jdbc.Driver" );
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name","root","abcd");
PreparedStatement del = con.prepareStatement ( "alter table student add email varchar(20);" );
del.executeUpdate();
con.close();
}
catch ( Exception e )
{
System.out.println ( e );
}
}
}
class Alter_Del
{
public static void main ( String args[] )
{
try
{
Class.forName ( "com.mysql.jdbc.Driver" );
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name","root","abcd");
con.close();
}
catch ( Exception e )
{
System.out.println ( e );
}
}
}
Delete Column:
import java.sql.*;class Alter_Del
{
public static void main ( String args[] )
{
try
{
Class.forName ( "com.mysql.jdbc.Driver" );
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name","root","abcd");
PreparedStatement del = con.prepareStatement ( "alter table student drop email;" );
del.executeUpdate();
con.close();
}
catch ( Exception e )
{
System.out.println ( e );
}
}
}
con.close();
}
catch ( Exception e )
{
System.out.println ( e );
}
}
}
0 Comments
Please don't enter any spam link in comment box.
Emoji