2
Most read
3
Most read
ALTER TABLE COMMAND
This is a part of DDL command . The ALTER table command is
used to change definition of existing table usually it can add
columns to a table. It can delete column and change their sizes.
In MY SQL alter table command is used…
1. To Add a New Column
2. To Add an Integrity Constraints
3. To Redefine a column (Data type, size, default value)
1. Adding Column:-
 We can add a new column in existing table with the
help of ALTER table command.
 To ADD a new column use ADD command with the
ALTER table command.
 The new column will be added with NULL values for
all rows currently in the table.
Syntax :-
ALTER TABLE tablename
ADD(newcolumname datatype(size));
Example :-
ALTER TABLE STUDENT
ADD(CITY VARCHAR(20));
Q1. To Insert a Record in new column.
UPDATE STUDENT
SET CITY=’ALWAR’;
Insert into student values(‘alwar’);--- wrong query
Modify command:-
We can use the MODIFY command with alter table
command to change structure of table.
We can change following parts of a table:-
 Data Type
 Size
 Default Value
 Order of Column
1) Data Type and Size
Syntax ;-
Alter Table tablename
Modify columnname newdatatype(new size);
Example:-
Alter table student
Modify phoneno varchar(20);
Alter table student
Modify city default ‘jaipur’;

More Related Content

PPTX
Basic SQL and History
PPTX
Integrity Constraints
PPTX
Packages in PL/SQL
PPTX
PPTX
Triggers
PDF
SQL Queries - DDL Commands
PPTX
SQL JOIN
PPT
Generics in java
Basic SQL and History
Integrity Constraints
Packages in PL/SQL
Triggers
SQL Queries - DDL Commands
SQL JOIN
Generics in java

What's hot (20)

PPTX
Java exception handling
PPTX
Introduction to Database, Purpose of Data, Data models, Components of Database
PPTX
database language ppt.pptx
PPTX
Mysql Crud, Php Mysql, php, sql
PPT
Constraints In Sql
PPT
PL/SQL
PPSX
Stacks Implementation and Examples
PPT
C++: Constructor, Copy Constructor and Assignment operator
PPTX
Sql fundamentals
PPTX
PPTX
Sql commands
PPT
Introduction to structured query language (sql)
PPTX
Lock based protocols
PPTX
Sql operator
PPTX
basic structure of SQL FINAL.pptx
PPTX
Sparse matrix
PPT
7.data types in c#
PPTX
2D Array
PPTX
SQL - DML and DDL Commands
PPTX
Java exception handling
Introduction to Database, Purpose of Data, Data models, Components of Database
database language ppt.pptx
Mysql Crud, Php Mysql, php, sql
Constraints In Sql
PL/SQL
Stacks Implementation and Examples
C++: Constructor, Copy Constructor and Assignment operator
Sql fundamentals
Sql commands
Introduction to structured query language (sql)
Lock based protocols
Sql operator
basic structure of SQL FINAL.pptx
Sparse matrix
7.data types in c#
2D Array
SQL - DML and DDL Commands
Ad

Similar to Alter table command (20)

PPTX
DML Commands in Database Management System.pptx
DOC
PPTX
Null values, insert, delete and update in database
PPTX
introdution to SQL and SQL functions
PPTX
Sql modifying data - MYSQL part I
PPTX
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
PPTX
Oracle: DML
PPTX
Oracle : DML
PDF
dbms lab manual
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
PPTX
2. DML_INSERT_DELETE_UPDATE
PPTX
Introduction to database and sql fir beginers
PPT
Oracle naveen Sql
PPT
Oracle naveen Sql
PDF
Assignment#02
DOCX
unit-5 sql notes.docx
PPTX
Sql tables
PDF
Sql alter table statement
PPT
DML Commands in Database Management System.pptx
Null values, insert, delete and update in database
introdution to SQL and SQL functions
Sql modifying data - MYSQL part I
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
Oracle: DML
Oracle : DML
dbms lab manual
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
2. DML_INSERT_DELETE_UPDATE
Introduction to database and sql fir beginers
Oracle naveen Sql
Oracle naveen Sql
Assignment#02
unit-5 sql notes.docx
Sql tables
Sql alter table statement
Ad

Recently uploaded (20)

PPTX
4. Diagnosis and treatment planning in RPD.pptx
PDF
Chevening Scholarship Application and Interview Preparation Guide
PPTX
PLASMA AND ITS CONSTITUENTS 123.pptx
PDF
Nurlina - Urban Planner Portfolio (english ver)
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2015).pdf
PDF
Disorder of Endocrine system (1).pdfyyhyyyy
PPTX
Reproductive system-Human anatomy and physiology
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PDF
Civil Department's presentation Your score increases as you pick a category
PDF
Hospital Case Study .architecture design
PDF
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PPTX
2025 High Blood Pressure Guideline Slide Set.pptx
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PPTX
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
PDF
The TKT Course. Modules 1, 2, 3.for self study
PPTX
Macbeth play - analysis .pptx english lit
PDF
Lecture on Viruses: Structure, Classification, Replication, Effects on Cells,...
4. Diagnosis and treatment planning in RPD.pptx
Chevening Scholarship Application and Interview Preparation Guide
PLASMA AND ITS CONSTITUENTS 123.pptx
Nurlina - Urban Planner Portfolio (english ver)
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2015).pdf
Disorder of Endocrine system (1).pdfyyhyyyy
Reproductive system-Human anatomy and physiology
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
Civil Department's presentation Your score increases as you pick a category
Hospital Case Study .architecture design
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
M.Tech in Aerospace Engineering | BIT Mesra
2025 High Blood Pressure Guideline Slide Set.pptx
Literature_Review_methods_ BRACU_MKT426 course material
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
The TKT Course. Modules 1, 2, 3.for self study
Macbeth play - analysis .pptx english lit
Lecture on Viruses: Structure, Classification, Replication, Effects on Cells,...

Alter table command

  • 1. ALTER TABLE COMMAND This is a part of DDL command . The ALTER table command is used to change definition of existing table usually it can add columns to a table. It can delete column and change their sizes. In MY SQL alter table command is used… 1. To Add a New Column 2. To Add an Integrity Constraints 3. To Redefine a column (Data type, size, default value) 1. Adding Column:-  We can add a new column in existing table with the help of ALTER table command.  To ADD a new column use ADD command with the ALTER table command.  The new column will be added with NULL values for all rows currently in the table. Syntax :- ALTER TABLE tablename ADD(newcolumname datatype(size)); Example :- ALTER TABLE STUDENT ADD(CITY VARCHAR(20));
  • 2. Q1. To Insert a Record in new column. UPDATE STUDENT SET CITY=’ALWAR’; Insert into student values(‘alwar’);--- wrong query Modify command:- We can use the MODIFY command with alter table command to change structure of table. We can change following parts of a table:-  Data Type  Size  Default Value  Order of Column 1) Data Type and Size Syntax ;- Alter Table tablename Modify columnname newdatatype(new size); Example:- Alter table student Modify phoneno varchar(20);
  • 3. Alter table student Modify city default ‘jaipur’;