Home > database >  [SQL] modify the table structure
[SQL] modify the table structure

Time:10-28

In figure cannot be modified, select tools - options - designer - table design and database design - (remove) to stop saving required to recreate the table changes

CodePudding user response:

Restart the SQL Settings first, then modify the table structure

CodePudding user response:

It is more convenient to direct language sentence changes

CodePudding user response:

Add fields:
The alter table table name add field name field type (field length) constraints;
Modify the fields (do not change the field name) :
The alter table table name modify field name field type (field length) constraints;
Remove fields:
The alter table table name drop field names;
Modify the fields (modify the field name) :
The alter table table name change the original name of the new field name field type (field length) field constraint;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

The original poster was meant to share it? Very good

But with a graphical interface is not appropriate, because it is not in the best way in the revision table structure, if you look at it to generate statements, or even to rebuild a new table, insert the data again,

If only learning or small tables, it doesn't matter,
Big table for a production environment, this operation can lead to very slow, even die, even if successful, a much slower rate than language sentence,

# 3 statements have a problem, suggest you refer to the following test case grammar:
 USE tempdb for 
GO
IF OBJECT_ID (' t1 ') IS NOT NULL
DROP TABLE t1
GO
The CREATE TABLE t1 (
Id INT PRIMARY KEY,
N NVARCHAR (20)
)
GO
- to create a test table above

- modify the table structure
The ALTER TABLE t1 ALTER COLUMN n INT the NOT NULL

CodePudding user response:

Yes, demo, development with the statement

CodePudding user response:

You need to modify the SSMS attribute, as shown in the link of http://www.maomao365.com/? P=5430
, please give it a try, if in doubt, instant communication!

CodePudding user response:

Direct language changed, there is no the tip, or change the SSMS design
  • Related