------------------ Windows Phones 7手机开发、.Net培训、期待与您交流! ----------------------
1.创建数据库、表
2.插入数据
3.t-sql 来 创建数据库、表、插入、删除、修改、查询(基本查询)表中的数据
--创建数据库
create database db;
create database db
on primary
(
name='db',
filename='c:\db.mdf',
size=3mb,
maxsize=100mb,
filegrowth=10%
)
log on
(
name='db_log',
filename='c:\db.ldf',
size=3mb,
maxsize=100mb,
filegrowth=10%
)
create table biaoming
(
lieming int identity(1,1) primary key,
lie2 varchar(50) not null
)
alter table biaoming
(
lieming int identity(1,1) primary key,
l2 varchar(50) not null
)
drop table biaoming
insert into biaoming(列1,列2,列3) values('a','d','c''c')
insert into biaoming values('a','d')
insert into biaoming
select 'a','b','c' union all
select 'a','b','c' union all
select 'a','b','c' union all
select 'a','b','c' union all
select 'a','b','c'
select * into newTable from oldTable where age>5
--只把oldTable的表结构拷贝一份,表中数据没有拷贝过来,因为
--对于oldTable表中的每条数据,Where条件1=2都返回false,所以没有查询出任何数据
--所以没拷贝任何数据
select * into newTable from oldTable where 1=2
--更新
update biaoming set lieming=值1,lie2=值,lie3=值,lie4=lie4+1 where lie5>10 and .. and .. or ...
--删除
delete from biao where age>60
--一次性删除表中所有数据
delete from biao
truncate table biaoming
select * from biaoming where ....
select name,age from biao where ...
主键
外键
------------------ Windows Phones 7手机开发、.Net培训、期待与您交流! ----------------------