To show the indexes of a specific table, you use the. IFK_TrackMediaTypeId Code language: Shell Session ( shell ) ![]() To show all indexes of the current database, you use the. fullschema Code language: CSS ( css ) Show indexes To show the schema and the content of the sqlite_stat tables, you use the. INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,įOREIGN KEY () REFERENCES "artists" ()ĬREATE INDEX ON "albums" () The following command shows the structure of the albums table. schema command will show the structures of all the tables. To display the structure of a table, you use the. Sqlite> Code language: Shell Session ( shell ) Show the structure of a table The sqlite3 uses the LIKE operator for pattern matching.įor example, the following statement returns the table that ends with the string es. If you want to find tables based on a specific pattern, you use the. The following commands open a new database connection to the chinook database and display the tables in the database. To display all the tables in the current database, you use the. exit Code language: Shell Session ( shell ) Show tables in a database To exit the sqlite3 program, you use the. databasesĬode language: Shell Session ( shell ) Exit sqlite3 tool database command again, the sqlite3 returns two databases: main and chinook. sqlite> ATTACH DATABASE "c:\sqlite\db\chinook.db" AS chinook Code language: Shell Session ( shell ) The following statement adds the chinook database to the current connection. To add an additional database in the current connection, you use the statement ATTACH DATABASE. databases command displays at least one database with the name: main.įor example, the following command shows all the databases of the current connection: sqlite>. To show all databases in the current connection, you use the. help Code language: Shell Session ( shell ) Show databases in the current database connection To show all available commands and their purpose, you use the. Sqlite> Code language: Shell Session ( shell ) Show all available commands and their purposes If you start a session with a database name that does not exist, the sqlite3 tool will create the database file.įor example, the following command creates a database named sales in the C:\sqlite\db\ directory: > sqlite3 c:\sqlite\db\sales.db If you want to open a specific database file when you connect to the SQlite database, you use the following command: > sqlite3 c:\sqlite\db\chinook.db open c:\sqlite\db\chinook.db Code language: Shell Session ( shell ) The following statement opens the chinook.db database: sqlite>. Sqlite> Code language: Shell Session ( shell )īy default, an SQLite session uses the in-memory database, therefore, all changes will be gone when the session ends. Use ".open FILENAME" to reopen on a persistent database. To start the sqlite3, you type the sqlite3 as follows: > sqlite3Ĭonnected to a transient in-memory database. The SQLite project delivers a simple command-line tool named sqlite3 (or sqlite3.exe on Windows) that allows you to interact with the SQLite databases using SQL statements and commands. For now, let's proceed to the next chapter.Summary: in this tutorial, we will introduce you to the most commonly used SQLite commands of the sqlite3 command-line program. You can perform restoration from the generated testDB.sql in a simple way as follows −Īt this moment your database is empty, so you can try above two procedures once you have few tables and data in your database. The above command will convert the entire contents of testDB.db database into SQLite statements and dump it into ASCII text file testDB.sql. dump dot command to export complete database in a text file using the following SQLite command at the command prompt. quit command to come out of the sqlite prompt as follows − ![]() Once a database is created, you can verify it in the list of databases using the following SQLite. ![]() If you have noticed while creating database, sqlite3 command will provide a sqlite> prompt after creating a database file successfully. This file will be used as database by SQLite engine. ![]() The above command will create a file testDB.db in the current directory. If you want to create a new database, then SQLITE3 statement would be as follows −Įnter SQL statements terminated with a " " Syntaxįollowing is the basic syntax of sqlite3 command to create a database: −Īlways, database name should be unique within the RDBMS. You do not need to have any special privilege to create a database. In SQLite, sqlite3 command is used to create a new SQLite database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |