डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Create Delete Alter MYSQL table

Create a table

CREATE TABLE IF NOT EXISTS table_name(
field_name DATATYPE(size) attribute1 attribute2,
...
...
...
);

Example
CREATE TABLE IF NOT EXISTS users(
id INT(10) AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(120),
last_name VARCHAR(120)
);

DROP table

DROP TABLE table_name;

Example

DROP TABLE users;

Alter Table

To add a new column

ALTER TABLE table_name ADD column_name DATATYPE
Example

ALTER TABLE users ADD address VARCHAR(255)

To drop column

ALTER TABLE table_name DROP COLUMN column_name;

Example

ALTER TABLE users DROP COLUMN address;

To modify column

ALTER TABLE table_name MODIFY COLUMN column_name DATATYPE

Example

ALTER TABLE users MODIFY COLUMN last_name TEXT
© 2016 - 2023, All Rights are Reserved.