in

System.Data.SQLite

An open-source, enhanced version of the SQLite database engine for Windows

how can i create a constraint?

Last post 11-03-2007 11:25 PM by Robert Simpson. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-03-2007 4:06 AM

    how can i create a constraint?

    hi,

    i am new at sqlite.before i used sqlserver ce.i want to create indexes and constraints,but sqlite gives errors.for example:

     

    first i create a table;

    tbl_stock.CommandText = _

    "CREATE TABLE TBL_STOK( " + _

    "stok_id int NOT NULL primary key," + _

    "stok_kod nvarchar(25) NOT NULL primary key," + _

    "stok_adi nvarchar(50) NOT NULL," + _

    "ana_grup_kod nvarchar(25) NULL," + _

    "ana_grup_adi nvarchar(25) NULL," + _

    "alt_grup_kod nvarchar(25) NULL," + _

    "alt_grup_ad nvarchar(25) NULL," + _

    "reyon_kod nvarchar(25) NULL," + _

    "reyon_ad nvarchar(25) NULL," + _

    "fiyat1 float NULL,fiyat2 float NULL," + _

    "fiyat3 float NULL,fiyat4 float NULL," + _

    "fiyat5 float NULL,fiyat6 float NULL," + _

    "fiyat7 float NULL,fiyat8 float NULL," + _

    "fiyat9 float NULL,fiyat10 float NULL,birim1_ad nvarchar(10) NULL,birim1_katsayi int NULL,birim1_agirlik float NULL," + _

    "birim2_ad nvarchar(10) NULL,birim2_katsayi int NULL,birim2_agirlik float NULL,birim3_ad nvarchar(10) NULL,birim3_katsayi int NULL,birim3_agirlik float NULL,toptankdv int not null,prkndekdv int not null,recno int null,dbcno int null)"

     

    but error gives like:  '"TBL_STOK" has more than one primary key'

     

     

     

     

    Sevilay Çelik
    Computer Engineer
    Software Developer
  • 11-03-2007 7:25 AM In reply to

    • Nate
    • Top 10 Contributor
    • Joined on 08-28-2005
    • Fort Collins, CO
    • Posts 67

    Re: how can i create a constraint?

    I am not trying to be a smart ass here but it told you what the exact error is. Get rid of one of the primary keys and make it a unique column.

    http://www.sqlite.org/lang.html 

    http://www.sqlite.org/lang_createtable.html 

  • 11-03-2007 7:27 AM In reply to

    • Nate
    • Top 10 Contributor
    • Joined on 08-28-2005
    • Fort Collins, CO
    • Posts 67

    Re: how can i create a constraint?

    Oh, and this page may be of some assistance to you

    http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSql

    Search for Primary Key 

  • 11-03-2007 11:25 PM In reply to

    Re: how can i create a constraint?

    remove "primary key" from stok_id and stok_kod and add this at the end:

    constraint pk_stok primary key (stok_id, stok_kod)

     

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems