SQL Modify Field length

Source: Internet
Author: User

Grammar:

Alter Table < table name >altercolumn< field name > new type name (length)

Example: If a named T1, the field name F1, the original F1 is varchar (3), now to varchar (10), then you can write:

Alter Table Alter column varchar (ten)

In general, you can use this statement to change the field name :

Alter Table column  to C


However, in practical applications, we tend to compile with j-sql, and J-sql does not support modifying field names, so if you must modify the field name, then only through the workaround, the specific idea is:
1. Create a new field, named C;
2. Copy the contents of field A to C;
3. Delete field A;

syntax for SQL to modify field lengths:

ALTER TABLE name modify field type;

Example code for SQL to modify field lengths

Alter Table VARCHAR2 (4000);

Standard SQL, applicable to any database

Alter Table varchar (a);

Modify Field name Name

ALTER TABLE  COLUMN  to COL2;

Add Field

Alter Table Add  Stationstate  CHAR(1)

Turn

SQL Modify Field length

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.