
#Sqlite command line based update
Update the department id for the employees using update command as shown below. The following examples adds deptid column to the existing employee table sqlite> alter table employee add column deptid integer

sqlite> alter table department rename to dept 5. The following example renames department table to dept using the alter table command. The following will execute all the commands from the insert-data.sql in the company.db database # sqlite3 company.db select * from employee ģ|Marketing|Los Angeles 4. Insert into department values(3,'Marketing','Los Angeles') Insert into department values(2,'Technology','San Jose') Insert into department values(1,'Sales','Los Angeles') Insert into employee values(105,'Rita Patel','DBA') Insert into employee values(104,'Jane Smith','Sale Manager') Insert into employee values(103,'Jason Bourne','Developer') Insert into employee values(102,'Raj Reddy','Sysadmin') Insert into employee values(101,'John Smith','CEO') You can execute all the insert statements from the sqlite command line, or you can add those commands into a file and execute the file as shown below.įirst, create a insert-data.sql file as shown below. The following example populates both employee and department table with some sample records. Note: To exit from the SQLite commandline “sqlite>” prompt, type “.quit” as shown above.Ī SQLite database is nothing but a file that gets created under your current directory as shown below. Sqlite> create table department(deptid integer,name varchar(20),location varchar(10)) Sqlite> create table employee(empid integer,name varchar(20),title varchar(10)) We’ve purposefully missed the deptid column in the employee table. This also creates an employee table with 3 columns (id, name and title), and a department table in the company.db database. The following example creates a database called company.db. Create a SQLite Database (and a Table)įirst, let us understand how create a SQLite database with couple of tables, populate some data, and view those records.

#Sqlite command line based install
You can also install SQLite database from source to get the latest version. If you don’t have sqlite installed, execute “yum install sqlite” to install it. This article explains all the basic SQL commands that you need to know to use the SQLite database effectively. While most of the commands in the SQLite are similar to SQL commands of other datbases like MySQL and ORACLE, there are some SQLite SQL commands that are different. This is a self-contained serverless database engine, which is very simple to install and use.

SQLite3 is very lightweight SQL database which focuses on simplicity more than anything else.
