- Create a database (TABLE_A table name)
the CREATE Database TABLE_A
- Delete database
--drop database TABLE_A
alter table [table] the Add [Field Name] int identity (1,1) not null - Add increment primary key
- drop delete drop view (delete view) drop table tabname (deleted table)
- Create Field create fields
the USE TABLE_A
Create Table tabname (
[ID] [int] the IDENTITY (1,1) the NOT NULL,
[name] [nvarchar] (50) NULL,
[Age] [nvarchar] (50) NULL,
[Gender] [nvarchar] (50) NULL,
[Prase] [decimal] (18 is, 0) NULL,
)
Alter the Add tabname Table Primary Key (COL)
GO --添加
INSERT INTO [TABLE_A].[dbo].[tabname](name,age,gender,prase) VALUES('小明','18','男','52')
GO - Modify
UPDATE TABLE_A.DBO.tabname SET gender = 'M ah' WHERE NAME = 'Bob'
drop view sr - Delete View
select sum(id) from [db].dbo.a
- **************************** * operation of the table columns ////////////////////////////////////////
ALTER table tabname drop tabname ----
- Add column (add a column to the table) (syntax) alter table table add [column] Field Name Data Type [Column Properties] [position]
ALTER Table tabname the Add ASS nvarchar (50) - add columns (add columns to the table )
- Modify the table name
the USE TABLE_A
EXEC sp_rename 'tabnames', 'tabname'
Go
- Modify the table name
sp_rename tabnames, tabname - Modify the table name
GO
alter table tabname add nda nvarchar (50 ) - was added to the column name table
- ******************************** ******* ******************************* operation table field /////// //////////////
- ************************************************************ benchmarking field operations // ***** **************
alter table tabname alter column name NVARCHAR (50) - Change the field (** ** data type)
ALTER TABLE tabname DROP COLUMN ass; - - delete table fields
alter table tabname add ass nvarchar (50 ) - add columns to a table (add a column to the table)
the ALTER TABLE tabname the Add SEED VARCHAR (20 is) - add columns to a table (add columns to the table)
alter table a add bpmid nvarchar (50) - add columns (add columns to the table)
GO
sp_rename 'tabname.name',newcolname,'nameds'
Go
- code changes a table name of a table in
the USE TABLE_A
EXEC the sp_rename, 'namesd', 'column' 'tabname [name].'
- Syntax modify the column name
--USE 'library name'
EXEC sp_rename '(to be modified) table column names.' 'Column names modified', 'column'