Re: Anyone knows how to use SQL object?
can i create a table whit custom colums useing this?
CREATE TABLE
sql-command ::=
CREATE [TEMP | TEMPORARY] TABLE table-name (
column-def [, column-def]*
[, constraint]*
)
sql-command ::=
CREATE [TEMP | TEMPORARY] TABLE [database-name.] table-name AS select-statement
column-def ::=
name [type] [[CONSTRAINT name] column-constraint]*
type ::=
typename |
typename ( number ) |
typename ( number , number )
column-constraint ::=
NOT NULL [ conflict-clause ] |
PRIMARY KEY [sort-order] [ conflict-clause ] |
UNIQUE [ conflict-clause ] |
CHECK ( expr ) [ conflict-clause ] |
DEFAULT value |
COLLATE collation-name
constraint ::=
PRIMARY KEY ( column-list ) [ conflict-clause ] |
UNIQUE ( column-list ) [ conflict-clause ] |
CHECK ( expr ) [ conflict-clause ]
conflict-clause ::=
ON CONFLICT conflict-algorithm
i'm srry.. i just paste it... i hope someone can read it and understand it... tnx again ^^
Re: Anyone knows how to use SQL object?
I'm learning the sql object too. It could be a few weeks before I have time to work on it but I'll share what I learn when I do :).
Your right though that the SQL object dosn't support all sql light commands and features :).
Re: Anyone knows how to use SQL object?
Hi !
Did you try the SQLDB Viewer that comes with the extension ? It is very useful to try your commands and it has got help.
Do you mean that you previously created a table and that you want to modify it, inserting a new column ? As many told you here, it's impossible with SQlite. You have to create a new table (with all your columns, including the new one) and then to copy the previous table in it.
Re: Anyone knows how to use SQL object?
You guys might want to learn SQL before trying to use the object.
Re: Anyone knows how to use SQL object?
Just to clear things up, it's not impossible to add columns to a table in SQLite but it may be impossible (as of now) to do it with the MMF2 extension. But nothing is really impossible. So that should go as a feature request for that extension. Please don't post misinformation to those who wish to learn.
Re: Anyone knows how to use SQL object?
A good request would be asking the author to update from SQLite version 2.1 to the latest one which supports a lot of new stuff and it's a little more stable. :)
Re: Anyone knows how to use SQL object?
Quote:
Originally Posted by byo
A good request would be asking the author to update from SQLite version 2.1 to the latest one which supports a lot of new stuff and it's a little more stable. :)
I think he said that for some reason he couldn't use the latest SQLite version in his extension. But I am sure that this extension is VERY powerful as it is. I used it and was very impressed. Of course it's not an easy extension, but I'm not sure that xhedgehogx is right : one could learn SQL with this extension (at least the basic commands). If one tries his commands in SQLDB Viewer.
Re: Anyone knows how to use SQL object?
In SQLite 2 you can put text in an INTEGER field for example, which makes data very easy to read. In SQLite 3 it's not that simple any more, and JSJ didn't manage to retrieve data-types, and thus had to switch to SQLite 2.
Sorry about misinformation about ALTER TABLE in SQLite, it seems that it indeed has basic support. Didn't try in MMF though, but it should work. I never used it, it seems pretty limited actually.
If you need to learn about SQL with SQLite, you should rely on a third party application, like Surmulot said. I never tried SQLite Viewer, but I use SQLiteManager. Since it's a php script, i would advise you to install WAMP which comes with SQliteManager.
After reading Locaz' message again, i'm wondering if he's not asking how to add a row (not column) into a table. If it's the case, then here is a dump from one of my tables :
# SQLiteManager Dump
# Version: 1.2.0
# http://www.sqlitemanager.org/
#
# Serveur: xxxxxxxxxxxxxxxxx
# Généré le: Saturday 09th 2008f February 2008 01:32 am
# SQLite Version: 2.8.17
# PHP Version: 5.2.0
# Base de données: xxxxxxxxx
# --------------------------------------------------------
#
# table structure : Skill_Tree
#
CREATE TABLE Skill_Tree ( Id INTEGER PRIMARY KEY, Id_Skill INTEGER NOT NULL, Id_Requis INTEGER NOT NULL );
CREATE INDEX Skill_Tree_Id_Skill ON Skill_Tree(Id_Skill);
CREATE INDEX Skill_Tree_Id_Requis ON Skill_Tree(Id_Requis);
#
# Data from the table table: Skill_Tree
#
INSERT INTO Skill_Tree VALUES ('1', '3', '1');
INSERT INTO Skill_Tree VALUES ('2', '7', '6');
INSERT INTO Skill_Tree VALUES ('3', '7', '5');
INSERT INTO Skill_Tree VALUES ('4', '4', '3');
INSERT INTO Skill_Tree VALUES ('5', '8', '4');
INSERT INTO Skill_Tree VALUES ('6', '12', '11');
INSERT INTO Skill_Tree VALUES ('7', '15', '14');
INSERT INTO Skill_Tree VALUES ('8', '13', '11');
INSERT INTO Skill_Tree VALUES ('9', '14', '13');
INSERT INTO Skill_Tree VALUES ('10', '17', '16');
INSERT INTO Skill_Tree VALUES ('11', '18', '17');
INSERT INTO Skill_Tree VALUES ('12', '19', '12');
INSERT INTO Skill_Tree VALUES ('13', '20', '19');
INSERT INTO Skill_Tree VALUES ('14', '16', '15');
INSERT INTO Skill_Tree VALUES ('15', '22', '21');
INSERT INTO Skill_Tree VALUES ('16', '24', '23');
INSERT INTO Skill_Tree VALUES ('17', '25', '24');
INSERT INTO Skill_Tree VALUES ('18', '27', '26');
INSERT INTO Skill_Tree VALUES ('19', '28', '25');
INSERT INTO Skill_Tree VALUES ('20', '29', '24');
# --------------------------------------------------------
hope this helps
EDIT : Note the Id Field is INTEGER PRIMARY KEY, ie AUTO-INCREMENT, so you don't really need to specify this value when INSERTing : INSERT INTO Skill_Tree (Id_Skill,Id_Requis) VALUES ('1','1').
Re: Anyone knows how to use SQL object?
you can store text in an interger field ? Well thats very poor programming, excessively wasting space and memory by acollating lots of memory to be able to store the text, when it should only use 1 byte for numbers up to 255, shambles!
Re: Anyone knows how to use SQL object?
hi, i've already learn about useing SQLite a few days ago.
My original question was about creating columns, Yves showed me a very interesting page (http://devzone.zend.com/node/view/id/760#Heading5)whit some examples and it solved my problem.
Now i can create them when i create the table, like Corentin sayd, lkethis:
CREATE TABLE table ( column1 PRIMARY KEY, column2, column3,....)
and then Insert the values
INSERT INTO table (column1, column2, column3) VALUES ('1','2','3')
and that was all i needed to know :P
but i'm still interested to learn more aboute indexes and what are the for.. so, Corentin can u please make me a short introduction ? i'll apreciate it, and tnx u all guys ^^ srry to not replied sooner... till next time!