How to modify field properties in SQLServer database
How to modify field properties in SQLServer database, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
How to modify field properties in SQLServer database
1: add fields to the table
Altertable [table name] add [column name] type
2: delete field
Altertable [table name] dropcolumn [column name]
3: modify the field type in the table (you can modify the type of the column, whether it is empty)
Altertable [table name] altercolumn [column name] type
4: add primary key
Altertable [Table name] addconstraint [constraint name] primarykey ([column name])
5: add unique constraints
Altertable [Table name] addconstraint [constraint name] unique ([column name])
How to modify field properties in SQLServer database
6: add a default value for a column in the table
Altertable [Table name] addconstraint [constraint name] default (default) for [column name]
7: add constraints
Altertable [Table name] addconstraint [constraint name] check (content)
8: add a foreign key constraint
Altertable [Table name] addconstraint [constraint name] foreignkey (column name) referencese another table name (column name)
9: delete constraint
Altertable [table name] addconstraint [constraint name]
10: rename the table
Execsp_rename' [original table name]','[new table name]'
11: rename column names
Execsp_rename' [table name]. [column name]','[table name]. [new list]'
This is the answer to the question about how to modify the field properties in the SQLServer database. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.