4 Replies - 2319 Views - Last Post: 06 June 2011 - 05:24 AM Rate Topic: -----

#1 maxfactor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-June 11

sqlite create table

Posted 03 June 2011 - 07:52 AM

Im novice to databases, but to sqlite i think im an completely idiot :helpsmilie:

the other day i was doing on tutorial on php, and in that tutorial was introduced to sqlite databases. trouble started first when sqlite version isn't from the tutorial time.

so i downloaded sqlite3 (newest one for windows), extraced i started.

it seemed the table was creating, as i was using INSERT ... into TABLE values, after every line i used SELECT * FROM books (the name of the table);

going after the tutorial it come to an .exit command to sqlite. so i did that too.

when i started sqlite again, and typed select * from books;

it gave me a respond: no such table.

p.s. the tutorial i was working on introduced version 2.xx and it got library.db, the version sqlite3 is just a .exe

i have never so stuck in any new program or any db system, this is weird.

that create table as much as was frustrating making it all over again, and all over again when i looked into folder in which was sqlite3 extracted nothing ever showed in it (mean: some sort of table or db).. does it have to be like that?

next thing i did, downloaded sqlitebrowser and created from there db and table in it, but i don't know how to :
see those databases in sqlite client or select, insert stuff in it, so in a way it seems useles as far the tutorial i am learning now. now i stuck at tutorial cause i can't get the table stay remembered. :dozingoff:
cound't find any answer anywhere that might help at the very beginning.

on sqlite site im totaly lost.

Is This A Good Question/Topic? 0
  • +

Replies To: sqlite create table

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5643
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: sqlite create table

Posted 03 June 2011 - 08:41 AM

You probably didn't specify a database file. Sqlite will happy let you bang away without one.

e.g.
baavgai@DIC$ sqlite3
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo(foo_id integer primary key, name string);
sqlite> insert into foo(name) values('Alpha');
sqlite> insert into foo(name) values('Bravo');
sqlite> select * from foo;
1|Alpha
2|Bravo
sqlite> .exit

baavgai@DIC$ sqlite3
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from foo;
Error: no such table: foo
sqlite> .exit

baavgai@DIC$ sqlite3 foo.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo(foo_id integer primary key, name string);
sqlite> insert into foo(name) values('Alpha');
sqlite> insert into foo(name) values('Bravo');
sqlite> select * from foo;
1|Alpha
2|Bravo
sqlite> .exit

baavgai@DIC$ sqlite3 foo.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from foo;
1|Alpha
2|Bravo



Make sure you name a file to store your work.
Was This Post Helpful? 1
  • +
  • -

#3 maxfactor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-June 11

Re: sqlite create table

Posted 04 June 2011 - 08:43 AM

thanks for reply,

my mistake was because didn't know how to make that first line (before version information)- i was double-click sqlite.exe
:hang:

and its about configuring sqlite to work in the system:

1) unziped sqlite into windows/system32 folder
2)Start->Run->CMD
3)type: sqlite3
...and after that exampledb.db

is the thing that is about to create db and with sql statements table in it.
:D
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 5,764
  • Joined: 08-June 10

Re: sqlite create table

Posted 04 June 2011 - 10:05 AM

View Postmaxfactor, on 04 June 2011 - 03:43 PM, said:

1) unziped sqlite into windows/system32 folder

This is generally a bad idea. That folder is for Windows system stuff. You really should avoid messing with it.

A better method is to unzip it in it's own directory someplace else, like in a C:\Program Files\SQLite\ folder for example, and then add that location to the PATH environmental variable. (See this for info on how to do that.)
Was This Post Helpful? 0
  • +
  • -

#5 maxfactor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-June 11

Re: sqlite create table

Posted 06 June 2011 - 05:24 AM

thanks for the tip,

lol i was following apress book: The Definitive guide to SQLite, 2nd edition

ok- it is removed from sys32 to own folder and added path
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1