-----Original Message----- From: Sebastian Tennant [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 28, 2007 12:56 PM To: sqlite-users@sqlite.org Subject: [sqlite] Importing data without a primary key
Hi all, I have a CSV file of data that doesn't include a column suitable to be the primary key. Should I edit the CSV data file before importing it (a pain to do), or is there an easy way to create (and populate) a primary key column once the data has been imported? Any suggestions much appreciated. Sebastian ====================================================== Hi Sebastian, There should not be a problem. The imported table will implicitly have its row number become a primary key. If you need to, though, you can later add a column to your table using the ALTER TABLE command. To use the row number, though, here's an excerpt from: http://www.sqlite.org/lang_expr.html A column name can be any of the names defined in the CREATE TABLE statement or one of the following special identifiers: "ROWID", "OID", or "_ROWID_". These special identifiers all describe the unique random integer key (the "row key") associated with every row of every table. The special identifiers only refer to the row key if the CREATE TABLE statement does not define a real column with the same name. Row keys act like read-only columns. A row key can be used anywhere a regular column can be used, except that you cannot change the value of a row key in an UPDATE or INSERT statement. "SELECT * ..." does not return the row key. [opinions expressed are my own, not those of my company] ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------