0% found this document useful (0 votes)
32 views

Modifying Mysql Databases and Updating Data in Mysql Table

This document discusses various ways to modify and update data in MySQL tables using SQL statements like ALTER TABLE, INSERT, UPDATE, DELETE. It covers adding, dropping and changing columns; adding constraints; copying tables; inserting, updating and deleting records.

Uploaded by

Babe Sultana
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Modifying Mysql Databases and Updating Data in Mysql Table

This document discusses various ways to modify and update data in MySQL tables using SQL statements like ALTER TABLE, INSERT, UPDATE, DELETE. It covers adding, dropping and changing columns; adding constraints; copying tables; inserting, updating and deleting records.

Uploaded by

Babe Sultana
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Modifying MySQL databases and

Updating Data in MySQL Table


Table modification using alter table
• Create a table and Automatic increment values:
• MySQL Add Column Examples :

• DROP an attributes/column from table persons

• Add an attributes/column to table persons in any position of column


• Drop database:
drop database database_name;
Drop table:

Drop table table_name;


• Add an attributes/column to table persons in the first column

• Add multiple attributes/column to table persons in single command

• DROP multiple attributes/column from table persons


 Add multiple attributes/column and constraints to
table persons in single command

alter table student add column 
salary int unique not null,
 add column dd int not null;
• Changing columns constraints using MySQL ALTER TABLE statement

• Changing columns constraints(key) using MySQL ALTER TABLE statement

Alter table persons_info change column ID ID int primary key;

ALTER TABLE persons_info DROP PRIMARY KEY, ADD PRIMARY KEY(salary, age);

Alter table persons_info add unique(salary,age);


• Changing columns name using MySQL ALTER TABLE statement
Inserting data into tables using MySQL INSERT
statement
• Insert values into person_info table

• Find all records from person_info


• MySQL copy table examples
CREATE TABLE IF NOT EXISTS student_backup LIKE student;
INSERT student_backup SELECT * FROM student;

• Find all records from new copied table


Updating data using MySQL UPDATE
statement
• UPDATE a column single value

• UPDATE a multiple columns single value


• Delete a record from a table

• Removing data using MySQL DELETE


statement

You might also like