zhyiwww
用平实的笔,记录编程路上的点点滴滴………
posts - 536,comments - 394,trackbacks - 0
学习时的一些脚本,记录下来:


drop table user_orders;

create table user_orders (    
    user_id int8 references userinfos(user_id),
    order_id int8 references orders(order_id)
);


drop table user_orders;

create table  user_orders (
    user_id int8,
    order_id int8,
    foreign key (user_id) references userinfos(user_id),
    foreign key (order_id) references orders(order_id)
);
drop table partners;
create table partners
(
 partner_id int8 primary key,
 partner_name varchar(80)
);

drop table partner_tables;

create  table partner_orders
(
    partner_id int8 references partners(partner_id),
    order_id int8 references orders(order_id),
   
    primary key (partner_id,order_id)

);

drop table prepaid_cards;

create table prepaid_cards
(
    prepaid_card_id int8 primary key,
    price float
)


drop table packages;


create table packages
(
  package_id int8 primary key,
  package_name varchar(80)
);

drop table package_cards;

create table package_cards
(
  package_id int8 references packages(package_id),
  prepaid_card_id int8 references prepaid_cards(prepaid_card_id),
 
  primary key (package_id,prepaid_card_id)
);

drop table prepaid_cards;

create table prepaid_cards
(

    prepaid_card_id int8 primary key,
    prepaid_card_no varchar(30)

)

drop table order_detials;

create table order_detials
(
    order_id int8 references orders(order_id),
    package_id int8 references packages(package_id),
    count int4 ,    
    primary key (order_id,package_id)
)

drop table aa;

create table aa
(
user_id int8 default nextval('seq_user_id') primary key ,
user_name varchar(40)
);


drop table category;

create table category
(
    category_id int8 primary key,
    parent_id int8 references category(category_id),
    category_name varchar(80)
);

drop sequence  seq_category_id ;
create sequence seq_category_id increment 1 start 300000;


alter table category  alter column category_id set default nextval('seq_category_id');
 



|----------------------------------------------------------------------------------------|
                           版权声明  版权所有 @zhyiwww
            引用请注明来源 http://www.blogjava.net/zhyiwww   
|----------------------------------------------------------------------------------------|
posted on 2009-05-20 17:37 zhyiwww 阅读(921) 评论(0)  编辑  收藏 所属分类: databasePostgres

只有注册用户登录后才能发表评论。


网站导航: