SQLite with Java

Introduction

Learn SQLite with Java

Verify SQLite

$ sqlite3
SQLite version 3.37.0 2021-12-09 01:34:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .quit

Introduction

$ sqlite3 anote.db
SQLite version 3.37.0 2021-12-09 01:34:53
Enter ".help" for usage hints.
sqlite> .help
sqlite> .headers on
# the contacts table has three colums
sqlite> create table contacts (name text, phone integer, email text);
sqlite> insert into contacts (name, phone, email) values ('jin', 4534567, 'jin@gmail.com');
sqlite> select * from contacts;
name|phone|email
jin|4534567|jin@gmail.com
sqlite> select name,phone from contacts;
jin|4534567

Backup and restore

sqlite> .backup anotebackup
sqlite> update contacts set email="none@gmail.com";
sqlite> select * from contacts;
jin|4534567|none@gmail.com
sqlite> .restore anotebackup
sqlite> select * from contacts;
jin|4534567|jin@gmail.com
sqlite> update contacts set email="renew@gmail.com" where name="jin";
jin|4534567|renew@gmail.com
sqlite> .tables
contacts
sqlite> .schema
CREATE TABLE contacts (name text, phone integer, email text);
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE contacts (name text, phone integer, email text);
INSERT INTO contacts VALUES('jin',4534567,'renew@gmail.com');

Leave a Reply

Your email address will not be published.

ANOTE.DEV