Last active
August 29, 2015 14:20
-
-
Save Code-Hex/07943d9275166b997407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use DBI; | |
use Teng; | |
use Teng::Schema::Loader; | |
my $dbh = DBI->connect('dbi:SQLite:quickstart.sqlite','','',{ | |
RaiseError => 1, | |
PrintError => 0, | |
AutoCommit => 1, | |
sqlite_unicode => 1, | |
}); | |
my $teng = Teng::Schema::Loader->load( | |
dbh => $dbh, | |
namespace => 'MyApp::DB', | |
); | |
$teng->do(q{ | |
CREATE TABLE user ( | |
id INT UNSIGNED NOT NULL PRIMARY KEY, | |
name VARCHAR NOT NULL, | |
age INT UNSIGNED NOT NULL | |
) | |
}); | |
# PRIMARY KEY制約が設定されたカラムには重複した値を格納することはできません。 | |
# ただしnullは複数のカラムに格納が可能です。 | |
# NOT NULL成約が設定されたカラムにはNULLを格納することができなくなります。 | |
# NULL NULL値 | |
# INTEGER 符号付整数。1, 2, 3, 4, 6, or 8 バイトで格納 | |
# REAL 浮動小数点数。8バイトで格納 | |
# TEXT テキスト。UTF-8, UTF-16BE or UTF-16-LEのいずれかで格納 | |
# BLOB Binary Large OBject。入力データをそのまま格納 | |
# http://so-zou.jp/web-app/tech/database/sqlite/data/data-type.htm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ sqlite3 quickstart.sqlite
sqlite> .exit
$ perl makeschema.pl
$ sqlite3 quickstart.sqlite
sqlite> .schema
sqlite> .exit