Name
Alter table -- change the definition of a table
Synopsis
ALTER TABLE [ ONLY ] name [ * ] action [, ... ]ALTER TABLE [ ONLY ] name [ * ] RENAME [ COLUMN ] column TO new_column
Oracel ALTER TABLE adds a primary key to the table primary key
Sql>Sql> CREATE TABLE EMP (empno number (4) is not NULL,2 ename varchar2 (10),3 Job Varchar2 (9),4 Mgr Number (4),5 HireDate Date,6 Sal Number (7, 2),7 Comm Number (7, 2),8 Deptno Number (2));
a table structure update, not all of the update operations will take you a long time.For example, you would like to update the user table with the default password of "666666", which is usually done by
mysql> ALTER TABLE user
-> MODIFY COLUMN pwd VARCHAR not NULL
' VALUES (' 1 ', ' smtphost ', ' email ', ' send mail server address ', ' smtp.163.com ');INSERT into ' auc_settings ' VALUES (' 2 ', ' title ', ' email ', ' email ' headers ', ' email verification ');INSERT into ' auc_settings ' VALUES (' + ', ' smstplcode ', ' SMS ', ' ali Big Fish ' template number ', ' sms_6740890 ');INSERT into ' auc_settings ' VALUES (' + ', ' smstype ', ' SMS ', ' Ali Big Fish Message type ', ' normal ');3. How does this relationship need to be maintained if there is a f
' VALUES (' 1 ', ' smtphost ', ' email ', ' send mail server address ', ' smtp.163.com ');INSERT into ' auc_settings ' VALUES (' 2 ', ' title ', ' email ', ' email ' headers ', ' email verification ');INSERT into ' auc_settings ' VALUES (' + ', ' smstplcode ', ' SMS ', ' ali Big Fish ' template number ', ' sms_6740890 ');INSERT into ' auc_settings ' VALUES (' + ', ' smstype ', ' SMS ', ' Ali Big Fish Message type ', ' normal ');3. How does this relationship need to be maintained if there is a f
MySQL Tutorial alter modify Word Name Table name structure Add column
ALTER TABLE statementThe ALTER TABLE statement is used to add, modify, or delete columns in an existing table.
SQ
Mysql tutorial alter name table name structure add Column
Alter table statementThe alter table statement is used to add, modify, or delete columns in an existing table.
SQL
Mysql changes the table structure: add, delete, modify, and adjust the field order to add a field: altertable 'user _ movement_log 'AddcolumnGatewayIdintnotnulldefault0AFTER 'regionid' (after which field is added) Delete the field: altertable 'user _ movement_log 'dropcolumnGatewayi
Mysql changes the table structure: add, delete, modify fields, adjust the field order to add fields:
the last column.
Alter column specifies a new default value for the COLUMN or deletes the old default value. If the old default value is deleted and the column can be NULL, the new default value is NULL. If the column cannot be NULL, MySQL assigns a default value. The default value is described in the 7.7 create
MySQL Tutorial PHP tutorial dynamically add Column ALTER table to tableAdd the MySQL statement of the column asALTER TABLE tablename ADD COLUMN columnName varchar () NOT NULL*/Database Tutorial Connection method$db = ' 111cnNet ';$conn = mysql_pconnect (' localhost ', ' root ', ' root ') or Die (Mysql_error ());mysql_s
ALTER TABLE Parse instance: sql:1. Add columns 2. Add columns, adjust column order 3. Increase the index 4. Increase the constraint 5. Increase the full-text index FULL-TEXT6. Change the default value of the column 7. Change the column name (type, order) 8. Do not change the column name 9. Delete Column 10. Delete the primary key 11. Delete Index 12. Change the character set Create a tableCREATE
type.Tips: we can also use change to achieve the modify effect. We only need to write the same field name after it.Add fields without integrity constraints Copy codeThe Code is as follows:Mysql> alter table person add sex boolean;Query OK, 0 rows affected (0.21 sec)Records: 0 Duplicates: 0 Warnings: 0 The sex here is followed by only the data type, without the integrity constraints.Add fields with integrit
Alter table table_name enable row movement, altertable_name
Row movement is literally interpreted as moving rows. by default, a row in an oracle data block does not move in its lifecycle, that is, its rowid does not change. however, in some scenarios, we want the row rowid to change. In this case, we need to start the row movement feature of the table.
Use the
original varchar (25) to varchar (20)
Modify Field name
The Code is as follows:
Mysql> alter table person change stu_name name varchar (25 );
Query OK, 0 rows affected (0.20 sec)
Records: 0 Duplicates: 0 Warnings: 0
Stu_name is the original name and name is the new name.
It should be noted that no matter whether the data type is changed, the subsequent data types must be written
If you do not modify th
Tags: reference HTML div mys full serve data type EOF modifiedSqlALTER TABLE Statement
ALTER TABLE StatementThe ALTER table statement is used to add, delete, or modify columns in an existing table.SQL ALTER
use change to achieve the modify effect. we only need to write the same field name after it.
Add fields without integrity constraints
Mysql> alter table person add sex boolean;
Query OK, 0 rows affected (0.21 sec)
Records: 0 Duplicates: 0 Warnings: 0
The sex here is followed by only the data type, without the integrity constraints.
Add fields with integrity constraints
Mysql>
SQL statement set of The alter TABLE in mysql, including adding, modifying, and deleting fields, renaming tables, and adding and deleting primary keys. This article introduces the SQL statement set of the alter table of the MySql database. if you are interested, learn about the SQL statement set of The
// Set the field in the existing table to auto_increment.Alter table tablename change ID int (2) not null auto_increment;
// Add a field and set the primary keyAlter table tabelname add new_field_id int (5) unsigned default 0 not null auto_increment, add primary key (new_fie
add index (ID)
3. Modify the ID field in the table employee as the primary key.
Alter table employee add primary key (ID)
4. Modify the ID field in the table employee as the UNIQUE index UNIQUE.
Alter table employee add unique (I
Employee table to salary and set its data type to int
ALTER TABLE Employee Change ID salary INT
6, delete the customer_id field in the Employee table
ALTER TABLE Employee DROP customer_id
7. Delete all primary keys in employe
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.