Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Sql modify field type
Sql modify field type
Altertable table name altercolumn field name typenotnull

1, modify the field name:

Altertable table name renamecolumnAtoB

2. Modify the default value of the field:

Altertable table name adds a default value (0) to a field name with a value. If a field has a default value, you need to delete the constraint of the field first and then add a new default value.

3. Add fields:

Change table name and add field name type notnulldefault0.

5. Delete fields:

Altertable table name? Dropcolumn field name.

Extended data:

Change other usage

1. Rename table

Change the name of the table and rename the new name of the table.

2. Delete the primary key in the table

AlterTABLE table name dropprimarykey

3. Add a primary key

alter tables j _ RESOURCE _ chargesADDCONSTRAINTPK _ SJ _ RESOURCE _ CHARGESPRIMARYKEY(resid,resfromid)

Add index

Changeable? Sj _ resource _ chargesaddidex _ name (name);

5.? Add a unique constraint index

Alter tables j _ resource _ chargesadduniqueemp _ name2 (card number);

6. Delete the index

altertabletablenamedropindexemp _ name;

7. Joint unique index

ALTERTABLEtablename? ADDUNIQUEINDEXINDEX_NAME? (school _id, settlement _ time);

Alter? Ignore? tabletablename? Supplement? Unique? Index (User ID, User Name)

References:

Baidu encyclopedia-alter table _ SQL command