Home > How to > Introduction to the SQLite database

Introduction to the SQLite database

Connect to your server with SSH (putty is a perfect tool for that). Once on the server you can create an SQLite database by typing this:

sqlite my_database.db

Once done you will get something that looks like that:

sqlite >

Technically your database is not yet created. If you check with your FTP client you will not see any new file. To have the database really created you need to add to it at least one table.

You can type in this command to create the “article” table:

CREATE TABLE article (id integer primary key, title varchar(10), description text);

To view the list of all the database tables you can type this command:

.tables

You should see your new created table name (article in our example).

Try to insert some data to this table by typing this:

INSERT INTO article (title, description) VALUES ('title 1', 'my description 1');
INSERT INTO article (title, description) VALUES ('title 2', 'my description 2');

Don’t forget to end each SQL statement with a “;” or else you will get an error !

You can after select all table rows by typing this command:

SELECT * FROM article;

As you can see it’s pretty simple to create an SQLite database and create and interact with its tables. The SQL syntax is mainly used so if you are familiar with MySQL you should be fine working with an SQLite database.

More information:
http://www.sqlite.org/docs.html

Categories: How to Tags: ,
  1. Ken Choi
    March 21st, 2011 at 00:00 | #1

    I had compiled sqlite3 for ARM and run on the S3C2410 Machine.
    At trying create DB, it is occured error message as below:
    sqlite3: error while loading shared libraries: /prj/lib/libsqlite3.so.0: symbol __xstat64, version GLIBC_2.1 not defined in file libc.so.6 with link time reference

    For compiling sqlite3, I had used ARM Cross Compiler.

    Could you help for my problem?

    I hope to be solved.

    Thanks & best regards,

    Ken

  2. Ken Choi
    April 7th, 2011 at 22:43 | #2

    I want to create new database not to the server but in the terminal(S3C2410, Linux Kernel 2.4.18) itself.
    I have used ARM compiler 2.95.2 and this error message is displayed after excuting
    “CREATE TABLE employee (Name varchar(20), Dept varchar(20));”.
    sqlite3: error while loading shared libraries: /prj/lib/libsqlite3.so.0: symbol __xstat64, version GLIBC_2.1 not defined in file libc.so.6 with link time reference

    After displaying error message, “sqlite3″ is terminated.

    Compile command is as below:
    ./configure –host=arm-linux –prefix=/home/sqlite/build/_install –disable-tcl

    Please help me.

  1. No trackbacks yet.