Windows builds SQLite database by script

Source: Internet
Author: User
Tags sqlite database

Create a SQLite database with a script

Create the following two files in turn:

1) One bat file: Script.bat

@ECHO offc:cd%homepath%/desktopsqlite3 test_db. DB < A.sqlsqlite3 test_db. DB. Dump > Result.sql

The Sqlite3 program can be downloaded from SQLite's official website to

2) A SQL file: A.sql, which stores the SQLite library script, as in the following example:

--sqlite script a.sql--Creating PERSONS class Create TABLE PERSONS (ID INTEGER PRIMARY KEY, NAME TEXT not NULL COLLATE nocase, SEX    CHAR not NULL, age INTEGER, TEL TEXT); Insert into PERSONS (name, sex, age, TEL) VALUES (' Tsybius ', ' M ', +, ' 12345678901 '); insert into PERSONS (name, sex, A    GE, TEL) VALUES (' GALATEA ', ' F ', 21, ' 98765432109 '); . Quit

You can create a database test_db by double-clicking Script.bat. DB, back up the established database to file Result.sql

The database created by the statement in A.sql will be saved in the Result.sql form as follows

PRAGMA Foreign_keys=off; BEGIN TRANSACTION; CREATE TABLE PERSONS (ID INTEGER PRIMARY KEY, NAME TEXT not null COLLATE nocase, SEX CHAR isn't null, age Intege R, TEL TEXT); insert into PERSONS values (1, ' Tsybius ', ' M ', +, ' 12345678901 '); insert into PERSONS values (2, ' GALATEA ', ' F ', 2 1, ' 98765432109 '); COMMIT;

Set up a good database, you can use SQLiteSpy.exe software to view

END

Windows builds SQLite database by script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.