First, create a new table
1. Creating a new table: CREATE TABLE tablename;
eg:create table Books;
2. Create tables and properties:
CREATE TABLE Books (
title_id INT Not_null auto_increment,
Title VARCHAR (150),
Pages INT,
PRIMARY KEY (title_id)
);
3. Add data to the table:
INSERT into Books (1, ' Linux in a Nutshell ');
Second, modify the table
1. Modify the table name:
ALTER TABLE tablename rename newtablename;
2. Modify the column type:
Alter TALBE tablename MODIFY COLUMNNAME NEWTYPE;
Eg:alter Table Books modify title varchar (n);
3. Join the column
ALTER TABLE tablename Add new column name type;
4. Modify column names
ALTER TABLE tablename change oldcolumnname new columnname type;
5. Delete columns:
ALTER TABLE tablename drop columnname;
Third, delete the entire table:
drop table tablename;
Iv. updating the data in the table
Update tablename set columnname=value where ();
If the statement is unconditional, the entire column will be modified to this value.
MySQL Common statements