Primary keys in CSV files ?

Results 1 to 3 of 3

Thread: Primary keys in CSV files ?

  1. #1
    Join Date
    Dec 1969

    Default Primary keys in CSV files ?

    I want to ensure that a value added to a particular field in a CSV file is unique when I use a SQL INSERT statement . That is, the value does not already exist in that field. Furthermore, if it does already exist that the record cannot be added.<BR><BR>Firstly, can a particular field be designed as a unique primary field key in a CSV file ? If it can, how is this achieved ?<BR><BR>If it cannot, how can you ensure the uniqueness of the value in that field when you execute the INSERT statement ? <BR><BR>The reason I am using a CSV file is that there are no other options in this instance to use other, more effecient, databases.<BR><BR>Any help with the SQL syntax and/or possible workarounds would be much appreciated.<BR><BR>Pete

  2. #2
    Join Date
    Dec 1969

    Default No

    A CSV file is just that, a *FILE*. It is not a database, in any way shape or form. It&#039;s just that the MS Jet engine is capable of treating a CSV file in *some* of the same ways it treats a table in a real database.<BR><BR>The only way I could see you could do this would be to test for the existence of that value first (see the ASPFAQs).<BR><BR>But, really, I find your statement that no other better way is available to you a bit hard to swallow.<BR><BR>At a minimum, you could use DBase files (.dbf format). And, really, you should be able to use Access files (.mdb) on any system you can use .csv files. Even if you can&#039;t use Access, you can still use Access-style SQL statements to do things like CREAT TABLE, etc.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default agree, at least use XML

    it will be a lot easier and fun to program against.<BR><BR>BUT A REAL DATABASE IS THE BEST. Use Access, MySQL, or if you are really hip, SQL Server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts