SQL server 从创建数据库到查询数据的简单操作
目录、
--创建数据库
create database db_Product
go
--使用数据库
use db_Product
go
--创建商品类型表 create table GoodsType ( IO int primary key identity(1,1), typename varchar(10)not null ) go --创建商品信息表 create table Goods ( Id int primary key identity(1,1), Typeld int foreign key references GoodsType(IO), Name varchar(20)not null, Price decimal(10,2) not null, ProductionDate datetime not null, Amount int not null ) go
insert into GoodsType values ('家电'), ('电子'), ('食品'), ('生活用品') insert into Goods values ('1','冰箱',3344,'2017-06-03',100), ('1','电视',1777,'2016-06-03',100), ('1','微波炉',333,'2017-02-26',100), ('2','手机',4500,'2017-05-07',100), ('2','显示器',1777,'2016-12-04',100), ('2','主机',1500,'2017-03-09',100), ('3','老干妈',9,'2017-07-06',100), ('3','爽口榨菜',3.6,'2017-06-08',100)
select * from GoodsType select * from Goods