SQL数据库的基本操作
2014-12-09 21:10
155 查看
欢迎来到unity学习、unity培训、unity企业培训教育专区,这里有很多U3D资源、U3D培训视频U3D教程、U3D常见问题、U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。
1.怎样使用代码创建数据库?
Create database 数据库名字
2.怎样利用创建的数据库?
Use 数据库名字
3.怎样建立表?
Create table 表名(
Id int identity (101,1) primary key,
Name varchar(20 ) not null,
Password varchar(10)
)
4.怎样查询所见表的信息?
Select*from 表名
5 怎样创建数据库的大小,存储路径?
Create database 数据库名
On primary(
name=数据文件别名,
filename=‘d:\data\data.mdf’,
size=25MB,
maxsize=50MB,
filegrowth=2MB
)
Log on(
name=日志文件别名,
filename=‘d:\data\log.ldf’,
size=10MB,
maxsize=20MB,
filegrowth=25%
)
6 向users表中加入数据
insert into users (name, password) values('张丹','123')
Insert into 表() values()
7 向users表中改数据
update users set name='黑球'where id=101
Update 表 set 要改的东西 where 来自哪里
8 删除表中的一行
delete from users where id='101'
Delete from 表where 要删除的那一行
9--批量的向表中插入数据
insert into users(name,password)
select'小红','456'union
select'小黑','789'
10 --复制表(表不存在)
select users.name,users.password into studentid from users
select*from studentid
11--向已经存在的表中插入批量的数据
insert into studentid select users.name,users.password from users
12--表不存在时
select users.name,users.password,identity(int,101,1)as id into stu from users
select*from stu
1.怎样使用代码创建数据库?
Create database 数据库名字
2.怎样利用创建的数据库?
Use 数据库名字
3.怎样建立表?
Create table 表名(
Id int identity (101,1) primary key,
Name varchar(20 ) not null,
Password varchar(10)
)
4.怎样查询所见表的信息?
Select*from 表名
5 怎样创建数据库的大小,存储路径?
Create database 数据库名
On primary(
name=数据文件别名,
filename=‘d:\data\data.mdf’,
size=25MB,
maxsize=50MB,
filegrowth=2MB
)
Log on(
name=日志文件别名,
filename=‘d:\data\log.ldf’,
size=10MB,
maxsize=20MB,
filegrowth=25%
)
6 向users表中加入数据
insert into users (name, password) values('张丹','123')
Insert into 表() values()
7 向users表中改数据
update users set name='黑球'where id=101
Update 表 set 要改的东西 where 来自哪里
8 删除表中的一行
delete from users where id='101'
Delete from 表where 要删除的那一行
9--批量的向表中插入数据
insert into users(name,password)
select'小红','456'union
select'小黑','789'
10 --复制表(表不存在)
select users.name,users.password into studentid from users
select*from studentid
11--向已经存在的表中插入批量的数据
insert into studentid select users.name,users.password from users
12--表不存在时
select users.name,users.password,identity(int,101,1)as id into stu from users
select*from stu