postgresql安装及常见错误处理
--表名和字段名如果加了双引号,系统会严格区分大小写,如果不加,则不区分大小写 /*创建用户者个人消费汇总表:Sta_User_Consume_Of_3Month*/ DROP TABLE IF EXISTS public.Sta_User_Consume_Of_3Month; --ID字段自增长主键(int(int4)型 CREATE TABLE public.Sta_User_Consume_Of_3Month( ID SERIAL PRIMARY KEY NOT NULL,UserID varchar(100) NOT NULL,UserName varchar(100) NOT NULL,PhoneNumber varchar(20) NOT NULL,UserAreaID varchar(100) NOT NULL,ConsumeSum float8 NOT NULL,ConsumeTimes int NOT NULL,AverageMoney float8 NOT NULL,LastConsumeTime timestamp(6),LastConsumeShop varchar(100),LastConsumeGoods varchar(100) ); --表说明 COMMENT ON TABLE public.Sta_User_Consume_Of_3Month IS '用户者个人消费汇总表'; --字段说明 COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.ID IS '主键ID'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.UserID IS '用户ID'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.UserName IS '用户名'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.PhoneNumber IS '用户手机号码'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.UserAreaID IS '用户所属区域ID'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.ConsumeSum IS '该用户在联盟内的消费总额(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.ConsumeTimes IS '该用户在联盟内的消费总次数(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.AverageMoney IS '该用户在联盟内的平均消费额(也即客单价,3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeTime IS '该用户最近一次的消费时间'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeShop IS '该用户最近一次的消费商家'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeGoods IS '该用户最近一次的消费商品'; /*创建用户行业消费统计表:Sta_User_Consume_3Month_By_Sector*/ DROP TABLE IF EXISTS public.Sta_User_Consume_3Month_By_Sector; CREATE TABLE public.Sta_User_Consume_3Month_By_Sector( ID SERIAL PRIMARY KEY NOT NULL,SectorID varchar(100) NOT NULL,LastConsumeGoods varchar(100) ); --表说明 COMMENT ON TABLE public.Sta_User_Consume_3Month_By_Sector IS '用户行业消费统计表'; --字段说明 COMMENT ON COLUMN public.Sta_User_Consume_3Month_By_Sector.ID IS '主键ID'; COMMENT ON COLUMN public.Sta_User_Consume_3Month_By_Sector.UserID IS '用户ID'; COMMENT ON COLUMN public.Sta_User_Consume_3Month_By_Sector.SectorID IS 'SectorID:行业ID(一级行业)'; COMMENT ON COLUMN public.Sta_User_Consume_3Month_By_Sector.ConsumeSum IS '该用户在该行业内的消费总额(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_3Month_By_Sector.ConsumeTimes IS '该用户在该行业内的消费总次数(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeTime IS '该用户在该行业内的最近一次的消费时间(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeShop IS '该用户在该行业内的最近一次的消费商家(3个月内)'; COMMENT ON COLUMN public.Sta_User_Consume_Of_3Month.LastConsumeGoods IS '该用户在该行业内最近一次的消费商品(3个月内)'; /*创建用户标签表:Sta_User_Tags*/ DROP TABLE IF EXISTS public.Sta_User_Tags; CREATE TABLE public.Sta_User_Tags( ID SERIAL PRIMARY KEY NOT NULL,TagID varchar(100),TagName varchar(100) ); --表说明 COMMENT ON TABLE public.Sta_User_Tags IS '用户标签表'; --字段说明 COMMENT ON COLUMN public.Sta_User_Tags.ID IS '主键ID'; COMMENT ON COLUMN public.Sta_User_Tags.UserID IS '用户ID'; COMMENT ON COLUMN public.Sta_User_Tags.TagID IS '目前对应行业IDSectorID,最细粒度行业'; COMMENT ON COLUMN public.Sta_User_Tags.TagName IS '目前对应行业名';