Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1177
  • Last Modified:

Create Table generating relation session_id_seq does not exist

I'm trying to export my tables from pg database and having some probs.  I'm using PG 8 on Windows machine and using Navicat or PG AdminIII. I dump the sql file and get no errors.  However, when I take it to another machine and try to run the querry to re-create my tables I get this error:     Error: relation "comm_session_id_seq" does not exist

The table in question has an auto increment field.  We are more familiar with mysql.  We tried to create an "auto increment" in postgres and believe this is the way they do it in this DB.  Can you tell me what is causing this error?  Is there an easier way to export tables from one DB to another?    Here is the querry.

-- ----------------------------
-- Table structure for public.account_types
-- ----------------------------
CREATE TABLE public.account_types(
id varchar(50) NOT NULL ,
name varchar(50) ,
discription varchar(50) ,
PRIMARY KEY (id)) WITHOUT OIDS;

-- ----------------------------
-- Table structure for public.billing_additional_fees
-- ----------------------------
CREATE TABLE public.billing_additional_fees(
id int4 NOT NULL ,
fee_name varchar(50) ,
fee_description text ,
fee_amount float4 ,
PRIMARY KEY (id)) WITHOUT OIDS;

-- ----------------------------
-- Table structure for public.comm_session
-- ----------------------------
CREATE TABLE public.comm_session(
id varchar(50) NOT NULL DEFAULT nextval('comm_session_id_seq'::regclass),
user_id varchar(50) DEFAULT 0,
ipaddress varchar(50) ,
start_time int4 ,
last_time int4 ,
loggedout bool DEFAULT false,
PRIMARY KEY (id)) WITHOUT OIDS;

-- ----------------------------
-- Table structure for public.countries
-- ----------------------------
CREATE TABLE public.countries(
id varchar(11) NOT NULL ,
countrynamelong varchar(100) ,
countrynameabbr varchar(50) ,
PRIMARY KEY (id)) WITHOUT OIDS;
0
codefaze
Asked:
codefaze
1 Solution
 
gheistCommented:
You have to add your custom type to new database before creating tables that use it.
0
 
earth man2Commented:
serial and bigserial implement the "auto increment" type.  I would use big integer type

CREATE TABLE public.comm_session(
id bigserial,
user_id varchar(50) DEFAULT 0,
ipaddress varchar(50) ,
start_time int4 ,
last_time int4 ,
loggedout bool DEFAULT false,
PRIMARY KEY (id)) WITHOUT OIDS;

also - try and put index and data on different tablespaces ( on different disk spindles)) for performance enhancement
0
 
codefazeAuthor Commented:
Did not know about bigserial.  That looks like it works.  Thx.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now