insert and heritage....

Поиск
Список
Период
Сортировка
Искать

insert and heritage....

От:
stephane parenton <stephane@parenton.com>
Дата:
hi everyone.... i'm having a slight problem understanding something.... 
I've bought a book about programming postgres, and there's a part 
concerning heritage.... so as i need to implement something like this in 
my work, i'm testing it.

I have a database called project (no matter the name)... It contains 
several tables. One of them is called "equipements" and has 5 columns :

CREATE TABLE equipements (id serial, adresseMac macaddr NOT NULL UNIQUE, 
adresseIp cidr, etat char, administrable bool,primary key(id));

so i entered a first value in this table with :
INSERT INTO equipements (administrable,adresseip,adressemac,etat) VALUES 
('false','192.168.0.1','FF:EE:DD:CC:BB:AA','0')\g

so far so good.

now, i have another table called "postetravail" that inherits from 
"equipements".... it was created like this :

CREATE TABLE postetravail (nom char) INHERITS (equipements);

i want this table to have quite the same columns as "equipments", but 
all i need for this entity is a name. When i look every column with sun 
one studio (for example), i see them right...

my first trouble comes from the state of "id", that is no more a primary 
key in "postetravail" while it was in "equipements", and it's located 
between "etat" and "nom"
now i have

administrable
adresseip
adressemac
etat
id
nom

while i was awaiting :

id (primary key)
administrable
adresseip
adressemac
etat
nom

the next problem concerns the insert :

INSERT INTO postetravail (administrable,adresseip,adressemac,etat,nom) 
VALUES ('false','192.168.0.2','FF:EE:DD:CC:BB:AB','1','big')\g
ERROR:  value too long for type character(1)

What is the problem.... I have the values in the correct order (i 
guess), and i keep having this error... i tried to add the id column in 
the insert, but it did not solve the problem....

Does somebody have clues for these 2 problems ?
regards
Stephane

FAQ