sql,t_user,t_root,t_goods,t_shop第二版

版权声明: https://blog.csdn.net/eds124/article/details/85952549
--create database mydata;
--use mydata;


drop table t_user;
create table t_user(
	username nvarchar(10) not null default N'默认用户名',	unique(username),           --用户名,需要不重名
	userpass nvarchar(10) not null default N'默认密码',                           --密码
	userediting bit not null default 0,         --编辑状态,多用户编辑时:默认为0,判断为0时才可以编辑,此时变成1,update之后再次变成0,别人方可编辑
	a1 bit not null default 0,                     --访问某页的权限开关
	a2 bit not null default 0,
	a3 bit not null default 0,
	a4 bit not null default 0,
	b1 bit not null default 0, 
	b2 bit not null default 0,
	b3 bit not null default 0,
	b4 bit not null default 0,
	c1 bit not null default 0,
	c2 bit not null default 0,
	c3 bit not null default 0,
	c4 bit not null default 0,
	d1 bit not null default 0,
	d2 bit not null default 0,
	d3 bit not null default 0,
	d4 bit not null default 0,
	usersmalldatetime smalldatetime not null default getdate(),      --最后编辑时间
	p_userid uniqueidentifier not null default newid(),	primary key(p_userid)      --主键
);
insert into t_user (username, userpass) values (N'user', N'user');
insert into t_user (username, userpass) values (N'张三', N'zs123');
insert into t_user (username, userpass) values (N'李四', N'ls456');
insert into t_user (username) values (N'王五');
insert into t_user (userpass) values (N'666');
select * from t_user order by username asc


drop table t_root;
create table t_root(
	rootname nvarchar(10) not null default N'默认管理员',	unique(rootname),
	rootpass nvarchar(10) not null default N'默认密码',
	rootsmalldatetime smalldatetime not null default getdate(),
	p_rootid uniqueidentifier not null default newid(),	primary key(p_rootid)
);
insert into t_root (rootname, rootpass) values (N'root', N'root');
insert into t_root (rootname, rootpass) values (N'admin', N'admin');
insert into t_root (rootname) values (N'aaaaaa');
insert into t_root (rootpass) values (N'passwd');
select * from t_root order by rootname asc


drop table t_goods
create table t_goods(
	goodsfenlei nvarchar(10) not null default N'默认分类',
	goodscode nvarchar(10) not null default N'默认编码', unique(goodscode),
	goodsname nvarchar(10) not null default N'默认名称',unique(goodsname),
	goodsdanjia money not null default 0,
	goodsdanwei nvarchar(10) not null default N'默认单位',
	goodssmalldatetime smalldatetime not null default getdate(),
	p_goodsid uniqueidentifier not null default newid(),	primary key(p_goodsid)
);
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r001','猪肉', 8, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r002','羊肉', 32, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r003','牛肉', 24, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r004','驴肉', 28, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r005','狗肉', 40, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r006','猫肉', 28, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r007','兔肉', 16, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r008','鸡肉', 5, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r009','鸭肉', 6, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('肉类','r010','鹅肉', 10, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c001','菠菜', 0.8, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c002','白菜', 0.4, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c003','芹菜', 2.2, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c004','油菜', 1.6, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c005','韭菜', 8, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c006','包菜', 1, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c007','生菜', 2.5, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c008','萝卜', 1.5, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c009','茭瓜', 2.5, '斤');
insert into t_goods (goodsfenlei,goodscode,goodsname,goodsdanjia,goodsdanwei) values ('蔬菜类','c010','冬瓜', 4.2, '斤');
select * from t_goods order by goodsfenlei asc, goodscode asc

drop table t_shop
create table t_shop(
	--f_goodsid uniqueidentifier not null default newid(),
	goodsfenlei nvarchar(10) not null default N'默认分类',
	goodscode nvarchar(10) not null default N'默认编码', 
	goodsname nvarchar(10) not null default N'默认名称',
	goodsdanjia money not null default 0,
	goodsdanwei nvarchar(10) not null default N'默认单位',
	shopshuliang decimal(12,4) not null default 0,
	shopsmalldatetime smalldatetime not null default getdate(),
	p_shopid uniqueidentifier not null default newid(), primary key(p_shopid)
);

猜你喜欢

转载自blog.csdn.net/eds124/article/details/85952549
T
今日推荐