Alter table: add, modify, and delete TABLE columns, constraints, and other TABLE definitions.
View column: desc 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 name;
Alter column name MySQL: alter table bbb change nnnnn hh int;
Modify the column name SQLServer: exec sp_rename 't_ student. name', 'nn ', 'column ';
Modify the column name Oracle: lter table bbb rename column nnnnn to hh int;
Alter table t_book modify name varchar (22 );
Sp_rename: the built-in Stored Procedure of SQL Server, which is used to modify the table definition.
Modify and delete data records in mysql
I believe many people have been familiar with the mysql database. When operating the mysql database, someone wants to delete or modify some data records in the mysql database.
I believe many people have been familiar with the mysql database. When operating the mysql database, someone wants to delete or modify some data records in the mysql database. The DELETE and UPDATE statements allow us to do this.
Modify record with update
UPDATE tbl_name SET column to be changed
WHERE record to be updated
The WHERE clause is optional. Therefore, if not specified, each record in the table is updated.
For example, in the pet table, we find that the gender of the pet Whistler is not specified, so we can modify this record as follows:
Mysql> update pet set sex = 'F' where name = "Whistler ";
Delete a record
The DELETE statement has the following format:
Delete from tbl_name WHERE record to be deleted
The WHERE clause specifies which records should be deleted. It is optional, but if it is not selected, all records will be deleted. This means that the simplest DELETE statement is also the most dangerous.
This query clears all contents in the table. Be careful!
To delete a specific record, you can use the WHERE clause to select the record to be deleted. This is similar to the WHERE clause in the SELECT statement.
Mysql> delete from pet where name = "Whistler ";
You can use the following statement to clear the entire table:
Mysql> delete from pet;