БД на Sybase

Тема в разделе "SQL", создана пользователем -next-, 13 ноя 2006.

Статус темы:
Закрыта.
  1. -next-

    -next- Гость

    Мужыки!!!! Помогие пож, какайта проблема с БД, не заполняется последняя таблица выкидывает ошибку, что может быть!? Проблемя с primary key а как исправить не знаю! Мот кто какой совет даст или поможет! Заранее спасибо!!!
    [sql]DBTOOL CREATE DATABASE 'd:\work\4\mydb.db'
    TRANSACTION LOG TO 'd:\work\4\mydb.log'
    IGNORE CASE
    PAGE SIZE 4096
    COLLATION '866rus'
    TRAILING SPACES;


    create table seller (
    idsel integer not null,
    name char (30) not null,
    opisanie char (30) not null,
    primary key (idsel)
    );

    create table divisions (
    iddiv integer not null,
    divname char (30) not null,
    idsel integer not null,
    idadress integer not null,
    primary key (iddiv)
    );

    create table adress (
    idadress integer not null,
    town char (30) not null,
    street char (30) not null,
    house integer not null,
    flat integer not null,
    primary key (idadress)
    );

    create table people (
    idman integer not null,
    surname char (30) not null,
    name char (30) not null,
    manORwomen char (10) not null,
    idadress integer not null,
    primary key (idman)
    );

    create table bilettype (
    idbiletypes integer not null,
    shortname char (5) not null,
    fullname char (20) not null,
    opisanie char (30) not null,
    primary key (idbiletypes)
    );

    create table months (
    idmonth integer not null,
    monthsortname char (10) not null,
    monthfullname char (30) not null,
    primary key (idmonth)
    );

    create table currprice (
    idmonth integer not null,
    idbiletypes integer not null,
    ishalfprice integer not null,
    year integer not null,
    many integer not null,
    primary key (idmonth,idbiletypes,ishalfprice,year)
    );

    create table prodagi (
    idprodagi integer not null,
    iddiv integer not null,
    idman integer not null,
    idbiletypes integer not null,
    idmonth integer not null,
    ishalfprice integer not null,
    year integer not null,
    dataofsell date not null,
    tyme char (30) not null,
    nuberofbilet integer not null,
    primary key (idprodagi)

    );

    ALTER TABLE divisions ADD FK_sel NOT NULL FOREIGN KEY(idsel) REFERENCES seller(idsel)ON UPDATE CASCADE ON DELETE CASCADE;



    ALTER TABLE divisions ADD FK_adress NOT NULL FOREIGN KEY(idadress) REFERENCES adress(idadress)ON UPDATE CASCADE ON DELETE CASCADE;



    ALTER TABLE people ADD FK_adres NOT NULL FOREIGN KEY(idadress) REFERENCES adress(idadress)ON UPDATE CASCADE ON DELETE CASCADE;


    ALTER TABLE currprice ADD FK_idmonth NOT NULL FOREIGN KEY(idmonth) REFERENCES months(idmonth)ON UPDATE CASCADE ON DELETE CASCADE;


    ALTER TABLE prodagi ADD FK_id NOT NULL FOREIGN KEY(idmonth,idbiletypes,ishalfprice,year) REFERENCES currprice(idmonth,idbiletypes,ishalfprice,year)ON UPDATE CASCADE ON DELETE CASCADE;

    ALTER TABLE currprice ADD FK_idbiletypes NOT NULL FOREIGN KEY(idbiletypes) REFERENCES bilettype(idbiletypes)ON UPDATE CASCADE ON DELETE CASCADE;

    ALTER TABLE prodagi ADD FK_iddiv NOT NULL FOREIGN KEY(iddiv) REFERENCES divisions(iddiv)ON UPDATE CASCADE ON DELETE CASCADE;

    ALTER TABLE prodagi ADD FK_idman NOT NULL FOREIGN KEY(idman) REFERENCES people(idman)ON UPDATE CASCADE ON DELETE CASCADE;

    insert into seller values ('1','Artur','bileti, internet-card');
    insert into seller values ('2','Galina','bileti');
    insert into seller values ('3','Irina','bileti,gazeti,');

    insert into adress values ('1','Minsk','Plexanova','12','2');
    insert into adress values ('2','Minsk','Rokossovskogo','112','223');
    insert into adress values ('3','Minsk','Gorovca','30','24');

    insert into people values ('1','Knysh','Denis','man','1');
    insert into people values ('2','Khlus','Galina','women','2');
    insert into people values ('3','Ivanova','Irina','women','3');


    insert into bilettype values ('1','BUS','Avtobus','bilet_na_avtobus');
    insert into bilettype values ('2','TRA','Tramvai','bilet na tramvai');
    insert into bilettype values ('3','TRO','Troleibus','bilet na troleibus');
    insert into bilettype values ('4','MET','Metro','bilet na metro');
    insert into bilettype values ('5','ATT','Avt+trol+tram','bilet na Avt+trol+trams');

    insert into months values ('1','jan','January');
    insert into months values ('2','feb','February');
    insert into months values ('3','mar','March');
    insert into months values ('4','apr','April');
    insert into months values ('5','may','May');
    insert into months values ('6','jun','June');
    insert into months values ('7','jul','July');
    insert into months values ('8','aug','August');
    insert into months values ('9','sep','September');
    insert into months values ('10','oct','October');
    insert into months values ('11','nov','November ');
    insert into months values ('12','dec','December');

    insert into divisions values ('1','Belsoy_1','1','3');
    insert into divisions values ('2','Belsoy_2','2','1');
    insert into divisions values ('3','Belsoy_3','1','2');
    insert into divisions values ('4','Belsoy_4','3','2');
    insert into divisions values ('5','Belsoy_5','2','1');


    insert into currprice values ('1','1','250','2006','500');
    insert into currprice values ('2','5','250','2006','500');
    insert into currprice values ('3','3','250','2006','500');
    insert into currprice values ('4','3','250','2006','500');
    insert into currprice values ('5','5','250','2006','500');


    insert into prodagi values ('1','1','2','2','1','250','2006','2006/11/01','den','123443');
    insert into prodagi values ('2','2','2','1','3','250','2006','2006/11/02','vecher','123444');
    insert into prodagi values ('3','3','1','3','5','250','2006','2006/11/03','den','123743');
    insert into prodagi values ('4','4','3','4','7','250','2006','2006/11/04','ytro','133443');
    insert into prodagi values ('5','5','2','5','12','250','2006','2006/11/05','den','123449');[/sql]
     
  2. ooo

    ooo Гость

    Проверьте в каком формате вы дату вставляете, не в строковом ,случаем?
     
Загрузка...
Статус темы:
Закрыта.

Поделиться этой страницей