sqlite

sqlite3 test.db
create table tb_test_self_type(int_type integer primary key, real_type real, text_type text);
insert into tb_test_self_type values(1,3.14159,'pi');
insert into tb_test_self_type values(2,23.14159,'pi2');
insert into tb_test_self_type values(3,33.14159,'pi3');
insert into tb_test_self_type values(4,43.14159,'pi4');
.database
.tables
.schema tb_test_self_type
.headers on
select substr(text_type,1,2) from tb_test_self_type limit 1 offset 0;

drop table tb_test_mysql_type;
--do not use auto_increment
--data of text/char type case sensitive
create table tb_test_mysql_type(
aid integer primary key ,
title varchar(255),
description text,
content text,
visible tinyint,
create_tm integer unsigned
);
insert into tb_test_mysql_type (aid,title,description,content,visible,create_tm)values(1,'title abc','descrition text','content text',1,1590582135);
insert into tb_test_mysql_type (aid,title,description,content,visible,create_tm)values(2,'title abc','descrition text','content text',1,3590582135);

 


==========================================
select datetime(1092941466, 'unixepoch')


select datetime('now'); --2020-05-27 13:04:58

SELECT strftime('%s','now'); -- 1590584942
SELECT strftime('%Y%m%d%H%M%S','now');--20200527130838

select strftime('%s','2004-01-01 02:34:56'); --1072924496
select datetime(1092941466, 'unixepoch'); -- 2004-08-19 18:51:06
SELECT strftime('%Y%m%d%H%M%S','2004-01-01 02:34:56')--20040101023456

=================================================
--export
.mode insert
.output all_testdb.sql
--<table name is optional>
.dump tb_test_self_type tb_test_mysql_type

--import
.read all_testdb.sql


----
sqlite3 -csv -header test.db "select * from tb_test_mysql_type"
sqlite3 -html -header test.db "select * from tb_test_mysql_type"
sqlite3 -column -header test.db "select * from tb_test_mysql_type"
sqlite3 -list -separator "=" -header test.db "select * from tb_test_mysql_type"

sqlite3 test.db "insert into tb_test_mysql_type (aid,title,description,content,visible,create_tm)values(3,'title abc','descrition text','content text',1,3590582135);"


BEGIN TRANSACTION;
.....
COMMIT;/ROLLBACK;

posted on 2020-05-27 22:17  阮減显  阅读(112)  评论(0编辑  收藏  举报

导航