[prev in list] [next in list] [prev in thread] [next in thread]
List: sqlite-users
Subject: Re: [sqlite] Table Creation Behaviour!!!
From: Hick Gunter <hick () scigames ! at>
Date: 2013-08-30 11:14:14
Message-ID: 9ca0d80979f0065d56aca797c27f3f408a039447 () localhost
[Download RAW message or body]
The default behaviour of INSERT when running into a PRIMARY KEY, UNIQUE or =
NOT NULL constraint is ABORT, i.e. back out any changes made by the current=
statement and return an error.
You may select a different behavior if your application logic so requires, =
the other choices being
ROLLBACK the complete transaction
FAIL stop processing but keep any changes before the offending row
IGNORE keep the old data
REPLACE keep the new data
// make sure a record in the other_table exists but keep any data already p=
resent
INSERT OR IGNORE INTO other_table (<key fields>) VALUES (<key values>);
// support data entry without keeping a write transaction open
SELECT * FROM this_table;
<display data on entry form and wait for user to finish>
INSERT OR REPLACE INTO this_table (<all fields>9 VALUES (<new values>);
-----Urspr=FCngliche Nachricht-----
Von: techi eth [mailto:techieth@gmail.com]
Gesendet: Freitag, 30. August 2013 11:43
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Table Creation Behaviour!!!
Thanks.
What about INSERT query behavior.
Is their any specific reason of allowing inserting same data set which is =
already present in database ?
Cheers -
On 8/30/13, Clemens Ladisch <clemens@ladisch.de> wrote:
> techi eth wrote:
>> I have open the connection, created the table by using CREATE TABLE
>> IF NOT EXISTS , doing some operation & closing the connection.
>>
>> If I again open the connection & try to do table creation again (With
>> same table name & same database file) then what will be the behavior?
>>
>> I am expecting it should not create table & return me error, because
>> their is already table with same name exists.
>
> RTFM <http://www.sqlite.org/lang_createtable.html>:
> | It is usually an error to attempt to create a new table in a
> | database that already contains a table of the same name. However, if
> | the "IF NOT EXISTS" clause is specified as part of the CREATE TABLE
> | statement and a table of the same name already exists, the CREATE
> | TABLE command simply has no effect (and no error message is returned).
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--------------------------------------------------------------------------
Gunter Hick
Software Engineer
Scientific Games International GmbH
Klitschgasse 2 =96 4, A - 1130 Vienna, Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: hick@scigames.at
This e-mail is confidential and may well also be legally privileged. If you=
have received it in error, you are on notice as to its status and accordin=
gly please notify us immediately by reply e-mail and then delete this messa=
ge from your system. Please do not copy it or use it for any purposes, or d=
isclose its contents to any person as to do so could be a breach of confide=
nce. Thank you for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic