Label: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 table MyClass, the type is int (4), and the default value is 0:Mysql> ALTER TABLE MyClass add passtest int (4) default ' 0 ';1) Gazzo PrimerMysql> ALTER
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 table MyClass, the type is int (4), and the default value is 0:Mysql> ALTER TABLE MyClass add passtest int (4) default ' 0 ';1) Gazzo PrimerMysql> ALTER
MySQL for relational databases (relational database Management System), this so-called "relational" can be understood as the concept of "table", a relational database consists of one or several tables.
We need to use the MySQL alter command when we need to modify the datasheet name or modify the Data table field.
Before starting this chapter tutorial, let's first create a table named: Testalter_tbl.
root@host# mysql-u root-p password;
Enter
To learn how to use MySQL databases, you must first understand the usage of various statements. The following describes how to use MySQL alter statements. If you are not familiar with MySQL alter statements, I believe that you can have a clear understanding of the use of MySQL alter statements.
// Primary key
Alter tab
The following article is mainly about the application of the MySQL alter syntax, we all know that the MySQL alter syntax in the actual application of the proportion is still very large, so understand the actual use of the MySQL alter syntax can be a good choice.
alter [IGNORE] TABLE tbl_name alter_spec [, Alter_spec ..
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 alter TABLE of mysql, including adding, modifying, and deleti
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 INDEX [index_name] (index_col_name,...)
or ADD PRIMARY KEY (index_col_name,...)
or ADD UNIQUE [index_name] (index_col_name,...)
or ALTER [COLUMN] col_name {SET DEFAULT lit
This article explains in detail the use of the ALTER command in MySQL syntax, which is a much more useful syntax, and the functionality is very powerful. Use Learning (to be built in advance) CREATE TABLE INT not NULL , CHAR (tennotnull, INTis notnull, INT ); Take a look at the new table.One, delete, add or modify table field
Delete a table field
The following command uses the ALTER
Alter Table' User_movement_log 'ADD columnGatewayidint not NULL default 0After ' RegionID ' (which field is added later)Alter TableX_connectionAdd' FEX-N752 'varchar(Ten)default NULL;//PRIMARY KeyAlter TableTabelnameAddnew_field_idint(5) unsigneddefault 0 not NULLAuto_increment,Add Primary Key(new_field_id);//Add a new columnAlter TableT2AddDtimestamp; Alter Ta
The following articles mainly introduce the practical use of MySQL ALTER syntax. We all know that the proportion of MySQL ALTER syntax in actual application is still very large, so you can have a good idea about the practical use of MySQL ALTER syntax.ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec...] in MySQL ALTER
If the index and table are placed in the same tablespace, please use alter table move with caution. This will change the index to UNUSABLE.
Procedure:
SQL> alter table TEST_COURSE MOVE;The table has been changed.SQL> set time on;09:28:48 SQL> alter table TEST_flow_dt move;The table has been changed.09:30:15 SQL> alter
MySQL Modify field length
ALTER TABLE news Modify column title varchar (130);
ALTER TABLE name modify column field name type;
For example: the title field in the news table is 100 characters in length and is changed to 130 characters
ALTER TABLE news Modify column title varchar (130);
Modify a field type
The Address Table City field in the database is varch
Tags: color add char log alt usage RIP name testOne: Modify table information 1. Modify the table name Alter Table to Sys_app; 2. Modify Table Annotations Alter Table ' System Information Table '; Second: Modify field information 1. modifying field types and annotations Alter table sys_application columnvarchar( name of ' app ') ; 2. Modify the field type
Tags: Oracle database alter UPDATEOnly for learning, review, in case forget, warm so know new!This is mainly about is the ALTER the use of words. First of all, I have a table that is only for learning. This table does not have a primary key constraint, a non-null constraint, or a FOREIGN key constraint.650) this.width=650; "Width=" 379 "height=" 117 "src="/e/u261/themes/default/images/spacer.gif "hspace=" s
The following articles mainly describe the actual operations of modifying the alter TABLE structure in MySQL. If you are interested in the actual operations of modifying the alter TABLE structure in MySQL, you can browse the following articles, the following is a detailed description of the relevant content.
2009-12-04 13: 51 ALTER [IGNORE] TABLE tbl_name alter_s
Mysql alter statement usage, adding, modifying, and deleting Fields
// Primary key
Alter table tabelname add new_field_id int (5) unsigned default 0 not null auto_increment, add primary key (new_field_id );
// Add a new column
Alter table t2 add d timestamp;Alter table infos add ex tinyint not null default '0 ';
// Del
1. In the actual project development process, previously created entity classes may need to add/delete fields, or change the properties of existing fields, such as the primary key growth strategy from self-increment to UUID type, then it will involveThe use of the ALTER TABLE statement in SQL.ALTER Table table_name Add column_name datatype add columns in tableALTER table table_name drop column column_name delete columns in a tableALTER TABLE tabl
1. In the actual project development process, previously created entity classes may need to add/delete fields, or change the properties of existing fields, such as the primary key growth strategy from self-increment to UUID type, then it will involveThe use of the ALTER TABLE statement in SQL.ALTER Table table_name Add column_name datatype add columns in tableALTER table table_name drop column column_name delete columns in a tableALTER TABLE tabl
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 keys. This article introduces how to use the mysql alter table statement through examples,
The MySQL ALTER syntax is as follows:
// Primary keyAlter 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 tablename ADD fieldname fieldtypeFor example:Alter table t2 ADD d TIMESTAMP;Alter table infos ADD ex tinyint not null default '0 ';// Delete a columnMysql> alter table table_name DROP field_
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.