PostgreSQL 8.0.0 �����ĵ���PostgreSQL �й� ������ | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 3. ������ | Fast Forward | Next |
����һ�� Chapter 2 ��� weather �� cities ������һ����������⣺����ȷ��û���˿����� weather �������һ���� cities ����û��ƥ���¼�������С� ��ͽ�ά����ı���ο��������� �ڼ����ݿ�ϵͳ�ʵ�֣����Ҳ��ʵ�֣�������Եķ��� ͨ�����ȿ��� cities �����Ƿ���ƥ��ļ�¼�� Ȼ�������߾ܾ��µ� weather ��¼�� ���������������⣬���ҷdz����㣬��� PostgreSQL ����Ϊ������Щ��
�µı�������������������������
CREATE TABLE cities ( city varchar(80) primary key, location point ); CREATE TABLE weather ( city varchar(80) references cities(city), temp_lo int, temp_hi int, prcp real, date date );
Ȼ��������ͼ����һ���Ƿ��ļ�¼��
INSERT INTO weather VALUES ('Berkeley', 45, 53, 0.0, '1994-11-28');
ERROR: insert or update on table "weather" violates foreign key constraint "weather_city_fkey" DETAIL: Key (city)=(Berkeley) is not present in table "cities".
�������Ϊ����Ϊ���Ӧ����ϸ���ڡ�����ݽ̳������ǾͲ��ٶ�˵�ˣ���������ο�Chapter 5��ȡ�������Ϣ�� ��ȷʹ��������ɽ��Ľ�������ݿ�Ӧ�ã���������ǿ�ҽ�����ѧϰ���ǡ�