create database
create database dbname
delete database
drop database dbname
Create a new table (the primary key id grows automatically, starting from 1 and incrementing by 1 each time)create table tablename(id int identity(1,1) primary key,uname varchar(10))
Modify table name
sp_rename tablename,newtablename
add a column
alter table emp add pwd varchar(10)
Delete a column (the value of the column can only be deleted if the value is null)
alter table s1 drop column pwd
Modify column names
sp_rename 'tablename.colname',newcolname,'column'
sp_rename 's2.uname','name','column'
renew
update s2 set name='aaa' where id=1
delete row
delete from s2 where id=3
View all tables under the database
select * from sysobjects where type='U'
Copy table structure and data
select * into sys_department_1 from sys_department
just copy the structure
法一:select * into b from a where 1 <>1
法二:select top 0 * into b from a