1.7. SQLite creates a database

发布时间 : 2025-10-25 13:32:45 UTC      

Page Views: 9 views

SQLite’s sqlite3 Command is used to create a new SQLite database. You do not need any special permissions to create a data.

1.7.1. Grammar

The basic syntax of the sqlite3 command is as follows:

$ sqlite3 DatabaseName.db 

In general, database names should be unique within RDBMS.

We can also use .open to create a new database file:

sqlite>.open test.db 

The above command creates the database file test.db, which is located in the same directory as the sqlite3 command.

The. Open command is also used to open an existing database. If the above command test.db If it exists, it will be opened directly, and if it does not exist, create it.

1.7.2. Example

If you want to create a new database < testDB.db >, the SQLITE3 statement looks like this:

$ sqlite3 testDB.db SQLite version 3.7.15.2 2013-01-09 11:53:05 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> 

The above command will create a file in the current directory testDB.db . This file will be used as a database by the SQLite engine. If you have noticed that after the sqlite3 command successfully creates the database file, it provides a sqlite> Prompt.

Once the database is created, you can use SQLite’s .databases Command to check if it is in the database list, as follows:

sqlite>.databases seq name file --- --------------- ---------------------- 0 main /home/sqlite/testDB.db 

You can use SQLite .quit The command exits the sqlite prompt, as follows:

sqlite>.quit $ 

1.7.3. .dump command

You can use SQLite from a command prompt .dump Click the command to export the complete database in a text file, as follows:

$sqlite3 testDB.db .dump > testDB.sql 

The above command will convert the entire testDB.db Put the contents of the database into the statement of SQLite and dump it to the ASCII text file testDB.sql Medium. You can recover from the generated testDB.sql in a simple way, as follows:

$sqlite3 testDB.db < testDB.sql 

At this time, the database is empty, once there are tables and data in the database, you can try the above two programs. Now, let’s move on to the next chapter.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。