LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   running sql script under sqlite3 (https://www.linuxquestions.org/questions/linux-newbie-8/running-sql-script-under-sqlite3-814500/)

miamagoo 06-16-2010 09:12 AM

running sql script under sqlite3
 
Hi, I am a newbie to sqlite3 db. I have been given a sql script with SQL commands in it to set up a new sqlite3 db. How do I run such a thing?

paulsm4 06-16-2010 09:23 AM

One way:

1. Start a terminal window

2. Run sqlite3 with your database filename:
Quote:

sqlite3 test.db
<= This will create "test.db" if it doesn't already exist
Substitute your actual DB filename for "test.db"
3. From inside the sqlite3 shell, run your script:
Quote:

.read MYSCRIPT.SQL
<= substitute your actual script name
Two good links:
http://souptonuts.sourceforge.net/re..._tutorial.html
http://www.sqlite.org/sqlite.html

'Hope that helps .. PSM

PS:
The first link also has some good information about using sqlite from C/C++ (and other languages), per your earlier posts...


All times are GMT -5. The time now is 09:54 PM.