Thursday, February 8, 2024

Basic SQLite Database commands

SQLite Commands

SQLite Commands for Database Management

  1. Invoke sqlite3 for a specific database:

    sqlite3 /tigergraph/tigergraph/data/ts3/db
  2. Attach a database in the sqlite3 shell:

    sqlite> ATTACH DATABASE "/tigergraph/tigergraph/data/ts3/db" as db;
  3. List tables:

    sqlite> .tables

    Output:

    datapoints
  4. Describe schema for a table (e.g., "datapoints"):

    sqlite> .schema datapoints

    Output:

    
    CREATE TABLE "datapoints" ("id" integer not null primary key autoincrement, "when" integer, "where" varchar(255), "who" varchar(255), "what" varchar(255), "detail" varchar(255), "submitted" integer, "written" integer);
    CREATE INDEX whenidx on datapoints ("when");
            
  5. Get the max_page_count of the database "db":

    sqlite> PRAGMA db.max_page_count;

    Output:

    1073741823
  6. Exit out of sqlite3 shell:

    sqlite> .quit

No comments:

Post a Comment