ALTER table: Add, modify, delete table columns, constraints, and other table definitions.
View column: Desc table name;
Modify table name: ALTER TABLE T_book Rename to BBB;
Add column: ALTER TABLE name add column name varchar (30);
Delete column: ALTER TABLE name drop column column name;
Modify Column name Mysql:alter table BBB change nnnnn hh int;
Modify Column name Sqlserver:exec sp_rename ' t_student.name ', ' nn ', ' column ';
Modify Column name oracle:lter table BBB Rename column nnnnn to HH int;
Modify Column properties: ALTER TABLE T_book modify name varchar (22);
Sp_rename:sqlserver built-in stored procedures, with the definition of modifying the table.
MySQL Modify, delete data records
MySQL database is believed that many people have contacted, in the MySQL database operation, someone would like to delete or modify the MySQL database in some data records.
MySQL database is believed that many people have contacted, in the MySQL database operation, someone would like to delete or modify the MySQL database in some data records. The DELETE and UPDATE statements enable us to do this.
Modify records with update
UPDATE Tbl_name Set the column to change
The record WHERE you want to update
The WHERE clause here is optional, so if you do not specify it, each record in the table is updated.
For example, in the pet table, we found that the sex of the pet Whistler was not specified, so we can modify this record as follows:
Mysql> Update pet Set sex= ' F ' where name= ' Whistler ';
Delete Records with delete
The DELETE statement has the following format:
Delete from Tbl_name WHERE to delete records
The WHERE clause specifies which records should be deleted. It is optional, but if not selected, all records will be deleted. This means that the simplest DELETE statement is also the most dangerous.
This query clears all the contents of the table. You must be careful!
To delete a specific record, you can select the record you want to delete by using the WHERE clause. This is similar to the WHERE clause in the SELECT statement.
Mysql> Delete from pet where name= "Whistler";
You can empty the entire table with the following statement:
Mysql>delete from Pet;