How to add new fields in MYSQL

Source: Internet
Author: User

I don't know how to add a new field to MYSQL? It doesn't matter. The following will teach you how to add new fields in MYSQL. I hope you will learn how to add new fields in MYSQL.

 
 
  1. Alter table 'samecity _ ALBUM 'change 'city' city 'varchar (255) character set latin1 COLLATE latin1_swedish_ci NOT NULL
  2. Alter table table_name ADD test4 ENUM ('y', 'n') not null Default 'y', add key (test4 );
  3. Add an enumerated field, which is not null. The default value is Y and is set as an index.
  4.  
  5. Alter table supe_aa add ex tinyint (1) not null default '0 ';
  6.  
  7. // 549830479 primary key
  8.  
  9. 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 549830479
  10.  
  11. Alter table t2 add d timestamp;
  12. Alter table infos add ex tinyint not null default '0'; // delete column 549830479
  13.  
  14. Alter table t2 drop column c; // rename column 549830479
  15.  
  16. Alter table t1 change a B integer;
  17. // Change the column type 549830479
  18.  
  19. Alter table t1 change B bigint not null;
  20. Alter table infos change list tinyint not null default '0 ';
  21. // Rename table 549830479
  22.  
  23. Alter table t1 rename t2; add index 549830479
  24.  
  25. Mysql> alter table tablename change depno int (5) not null;
  26. Mysql> alter table tablename add index name (field name 1 [, field name 2…]);
  27. Mysql> alter table tablename add index emp_name (name); index 549830479 with primary keywords added
  28.  
  29.  
  30. Mysql> alter table tablename add primary key (id); add the index 549830479 with the unique restriction
  31.  
  32. Mysql> alter table tablename add unique emp_name2 (cardnumber); delete an index 549830479
  33.  
  34. Mysql> alter table tablename drop index emp_name; Modify table: 549830479
  35.  
  36. Add field: 549830479
  37.  
  38. Mysql> alter table table_name ADD field_name field_type; modify the original field name and type: 549830479
  39.  
  40. Mysql> alter table table_name CHANGE old_field_name new_field_name field_type; Delete field: 549830479
  41.  
  42. Mysql> alter table table_name DROP field_name;

The above is how MYSQL adds new fields.

Common MySQL auto-increment Fields

Mysql character encoding method

Statement for modifying fields in mysql

How to delete multiple tables in MySQL

Common MySQL auto-increment Fields

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.