sql学习3
时间:2010-09-25 来源:为你抒写
数据库简单的用处(三)
if exists (select from sysdatabases where name='zhongfei') drop database zhongfei go create database zhongfei go use zhongfei go create table T_Person (FName varchar(20) primary key,Fage int,FRemark varchar(20)); create table T_Debt(FNumber varchar(20) primary key,FAmount numeric(10,2) not null,FPerson varchar(20),Foreign key(Fperson) references T_Person(Fname)); go select from T_Person select from t_debt use master drop table T_person drop table T_Debt insert into T_Person(FName,FAge,FRemark) values('tom','18','usa') insert into T_Person(FName,FAge,FRemark) values('nanwang','18','usa') insert into T_Person(FName,FAge,FRemark) values('xiaofeng','18','usa') insert into T_Person(FName,FAge,FRemark) values('nana','18','usa') insert into T_Person(FName,FAge,FRemark) values('feifei','20','china') insert into T_Person values('zhengzheng','17','english') insert into T_Person values('kuku','19','banana') insert into T_Person values('shuaishuai','25','china') insert into T_Debt(FNumber,FPerson) values('1','tom') insert into T_Debt(FNumber,FAmount,FPerson) values('1','200','tom') insert into T_Debt(FNumber,FAmount,FPerson) values('2','300','nana') update T_Person set FRemark='sunan' update T_person set Fage =16 where Fname='tom' update t_person set fage = 13 where fname='nana' or fname='shuaishuai' update t_person set fremark='china' where fname='nana' update t_debt set famount = 123 where fperson='tom' delete from t_person delete from t_debt delete from t_person where fage18 or fremark ='china' 相关阅读 更多 +