Issue 119009

Summary: Primary Index cannot be created
Product: Base Reporter: tommyads
Component: codeAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Normal    
Priority: P3 CC: issues, r4zoli
Version: OOO330m20   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
sample database-table containing table without primary key none

Description tommyads 2012-03-03 10:00:42 UTC
Created attachment 77271 [details]
sample database-table containing table without primary key

Create a new empty database.
In calc, select some cells, with header-line on top, copy the cells.
Paste the cells as a new table in the database, in the wizard don't create a primary key.
Then edit the table-definition and set a primary key, then save. 

But the index is not created or saved, and therefore editing the table is not possible.
See attached an example: you cannot define a primary key for this table!
Comment 1 r4zoli 2012-03-03 13:58:14 UTC
All tables needs primary key in Base to add data.

The copy table wizard contains option in first window when you can select it and it add PK with new ID column. If you miss that step, the copy wizard warns you to add PK to your table. If you ignore that warning, the wizard create table without PK. This is a known bug, I needs to find that, and mark this as duplicate of that bug.

But you can use with menu Tools>SQL...   SQL command window, and execute this commmand: 

ALTER TABLE "Tabelle1" ADD  "ID"  INTEGER GENERATED BY DEFAULT AS IDENTITY BEFORE "a".  
If it is run successfully, add new "ID" field with autoincrement values. After that refresh table, View>Refresh Table... then you can add more data to your table