SQlite 現在日付をDEFAULT値として設定する方法

環境
MariaDB 10.10.2

構文
CREATE TABLE テーブル名(カラム名 DEFAULT CURRENT_TIMESTAMP, …);
現在日付をDEFAULT値として設定する「DEFAULT」に「CURRENT_TIMESTAMP」を指定します。

操作方法
「testuser」というテーブルのカラム「created_date」にデフォルト値「CURRENT_TIMESTAMP」を設定し
SQL構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
CREATE TABLE testuser(id integer, name text, created_date default CURRENT_TIMESTAMP);
CREATE TABLE testuser(id integer, name text, created_date default CURRENT_TIMESTAMP);
CREATE TABLE testuser(id integer, name text, created_date default CURRENT_TIMESTAMP);

 

SQLite

Posted by arkgame