Learn about mysql alter table add column example, we have the largest and most updated mysql alter table add column example information on alibabacloud.com
Mysql alter table command arrangement, mysqlalter
The mysql alter table command is used to modify the TABLE structure, such as adding/modifying/deleting fields, indexes, and primary key
The alter ADD command is used to increase the table's fields.Alter ADD command format: ALTER TABLE name add field type other;For example, a field passtest is added to
// Primary key
Alter table tablename add new_field_id int (5) unsigned default 0 not null anto_increment, add primary key (new_field_id );
// Add a new columnMysql> alter table tablena
The MySQL alter syntax is as follows:
ALTER [IGNORE] TABLE tbl_name alter_spec [, Alter_spec ...]
Alter_specification:
ADD [COLUMN] create_definition [a] After column_name]
or ADD
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
The MySQL ALTER TABLE statement can modify the basic structure of the table, such as adding fields, deleting fields, adding primary keys, adding indexes, modifying field data types, renaming tables, and so on, and this article introduces the use of MySQL
The ALTER TABLE statement is used to add, modify, or delete a column's original table in an existing table:first, Alter adds a new column to the table
syntax:ALTER
Alter table only allows adding columns that can contain null values or specified the default definition.
If:
If exists (select 1 from sysobjects where name = n' tab _ test') and not exists (select 1 from sysobjects A, syscolumns B where B. id =. ID and B. name = n' Col _ test' and. name = n' tab _ test ')Alter table ta
Label:Get ready:CREATE table t (x int,y int); Usage 1:Modifying a column's data classALTER TABLE t modify column y nvarchar (32); Usage 2:Add a column to a tableALTER TABLE t add
The following articles mainly describe the information related to MySQL Alter Table function leakage. If you are using MySQL Alter Table, you can use the following articles to study it!
Affected Systems:
MySQLABMySQL5.1.x
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 i
ALTER TABLE changes the table to the current character set. If a duplicate key error is encountered during the execution of the ALTER TABLE operation, the new character set maps 2 keys to the same value or the table is corrupted.
The MySQL Replication encountered the following error message: (mysql> show slave status\g # simplified message below)
last_errno:1580Last_error:error ' You cannot ' ALTER ' a log table if logging are enabled ' on query. Default database: ' MySQL '. Query: ' ALTERTABLE Slow
A collection of SQL statements for the ALTER TABLE of MySQL, including adding, modifying, deleting fields, renaming tables, adding, deleting primary keys, and so on.
1: Delete Column
ALTER table "
SQL Server has a strange problem (2000/2005 all have this problem ):
The mm_bjjhmx table has the ID of the auto-increment column of the primary key, and a column "sequence number" is also required ".
Run the following statements:
Select Identity (INT, 1, 1) XH, A. * into # TBFrom mm_bjjhmxWhere bjjhid = 4Order by A. bjbm, A. bjmc;Select * from # TBDrop
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.