can't add field PRIMARY KEY

Issue #158 resolved
Former user created an issue

Originally reported on Google Code with ID 158

In phpliteadmin i
- choose a table
- choose 'structure'
- choose 'Add 1 field at end of table'

the field have for name 'id', for type INTEGER and IS A PRIMARY KEY

phpliteadmin andswers :

Error: Cannot add a PRIMARY KEY column

----------------

I use phpLiteAdmin v1.9.3 ... here for example : 
http://francois.couloigner.free.fr/sqlite/phpliteadmin.php

Reported by fcouloigner on 2012-11-24 11:29:40

Comments (3)

  1. Christopher Kramer
    Thanks for reporting this issue. In fact it's an SQLite limitation. But we can do a
    workaround that creates a copy of the table with the added primary key and replace
    the original with the copy like we do for all other ALTER TABLE statements that SQlite
    doesn't support.
    
    In fact this is nearly the same issue as issue #79 (creating vs. modifying primary
    key).
    
    I'll implement this in my alter table workaround.
    

    Reported by crazy4chrissi on 2012-11-25 00:09:29 - Status changed: Accepted

  2. Christopher Kramer

    Reported by crazy4chrissi on 2013-03-01 00:15:35 - Labels added: Type-Enhancement - Labels removed: Type-Defect

  3. Christopher Kramer
    It is now possible to add primary keys to existing columns since r444 and to add new
    columns that are primary key since r445.
    This is only possible if there is no primary key yet.
    If there is one, you will get this error:
    table "tablename" has more than one primary key
    
    With r444, it is already possible to add primary keys, also compound ones, if there
    is no such key. So only thing really missing is a possibility to drop the primary key.
    But that's another issue (which I will open in a minute).
    

    Reported by crazy4chrissi on 2013-12-29 23:17:59 - Status changed: Fixed - Labels added: Target-1.9.5

  4. Log in to comment