· 8 years ago · Mar 12, 2018, 06:52 PM
1#!/bin/bash
2sqlite ex3.db
3create table t1(f1 integer primary key,f2 text)
4
5#!/bin/bash
6
7sqlite3 ex3.db "create table t1(f1 integer primary key,f2 text)"
8
9#!/bin/bash
10sqlite3 mydatabase <<SQL_ENTRY_TAG_1
11SELECT * FROM sqlite_master;
12SQL_ENTRY_TAG_1
13
14#!/bin/bash
15echo 'create table t1(f1 integer primary key,f2 text);' | sqlite ex3.db
16
17#!/bin/bash
18DB_NAME=ex3.sqlite
19DB_TABLE=t1
20
21sqlite3 $DB_NAME << EOF
22
23DROP TABLE IF EXISTS $DB_TABLE;
24
25CREATE TABLE $DB_TABLE (
26 "f1" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
27 "f2" TEXT NOT NULL DEFAULT "f2-text"
28);
29
30INSERT INTO $DB_TABLE (f1, f2) VALUES (1, "text 1");
31INSERT INTO $DB_TABLE (f1, f2) VALUES (2, "text 2");
32
33EOF
34
35$sqlite3 -line teste.db 'create table table_name (field_name integer)'
36$sqlite3 -line teste.db 'insert into table_name (123)'
37$sqlite3 -line teste.db 'select * from table_name'