sqlite常用sql語句

來源:互聯網
上載者:User

 

--返回UTC時間
select CURRENT_TIMESTAMP;
--返回本地時間
select datetime(CURRENT_TIMESTAMP,'localtime');
--時間轉換,時間轉換時要求: yyyy-MM-dd,例如: 2008-08-09
SELECT datetime('2008-12-22') AS [My Time];
SELECT datetime('2008-12-22') AS "My Time";--必須為雙引號

SELECT  date('now', 'localtime');--返回本地日期

SELECT  time('now', 'localtime');--返回本地目前時間

select CURRENT_TIME;--返回當前UTC時間

select CURRENT_DATE;--返回當前UTC日期

select julianday('2008-12-22') - julianday('2008-12-21');--日期比較

--Compute the current date.
SELECT date('now');
--Compute the last day of the current month.
SELECT date('now','start of month','+1 month','-1 day');

--Compute the date and time given a unix timestamp 1092941466.
SELECT datetime(1092941466, 'unixepoch');

--Compute the date and time given a unix timestamp 1092941466, and compensate for your local timezone.
SELECT datetime(1092941466, 'unixepoch', 'localtime');

--Compute the current unix timestamp.
SELECT strftime('%s','now');

--Compute the number of days since the signing of the US Declaration of Independent.
SELECT julianday('now') - julianday('1776-07-04');

--Compute the number of seconds since a particular moment in 2004:
SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');

--Compute the date of the first Tuesday in October for the current year.
SELECT date('now','start of year','+9 months','weekday 2');

--Compute the time since the unix epoch in seconds (like strftime('%s','now') except includes fractional part):
SELECT (julianday('now') - 2440587.5)*86400.0;

Select rowid,* From keys order by rowid asc Limit 5 Offset 5 ;--SQLite分頁顯示,表示跳過5行,再取5行,即第二頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.