1.7. SQLite creates a database

发布时间 :2025-10-25 12:31:14 UTC      

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.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.