ローカル参照と公開済みの全モードを含む完全パッケージをインストールします。
install postgresqlpostgresqlpostgresql [options] · postgresql : <sql>postgresql現在の
postgresql -c <host> <user> [database] [-p <port>] [-n] [-m [name]]接続する;-n を使わない場合はパスワードを別入力で要求
-use <database>再接続して別のデータベースを選択
-lデータベースを一覧表示
-tpublic テーブルとビューを一覧表示
-s <table>列とデータ型を表示
-n <table> [rows]テーブル行をプレビュー
-f <table> <text> [rows]テーブルの各列からテキストを検索
-o <table> [-j|-csv] [file] [-f]テーブル行をエクスポート
-a <table> : <json>JSON オブジェクトから1行追加
-w <table> <field> <value> : <json>一致する行を JSON オブジェクトで更新
-d <table> <field> <value>一致する行を削除
-m [name]現在の接続を .lil.key に保存。既定名はデータベース名
-M <name>保存済み接続を削除
-k [name]保存済み接続を一覧表示、またはパスワードを表示せずに1件確認
-K <name>保存済み接続を使って接続
-e切断して接続情報を消去
postgresql : <sql>ネイティブ SQL を実行
postgresql load <file.sql|file.json>SQL を実行するか lil 論理 JSON ダンプを復元
postgresql dump [file.json] [-f]public テーブルの論理 JSON ダンプを作成
-s products は列、-n products 2 は行を表示し、-f products shoe 2 で検索できます。: の後に SQL を指定でき、-o products -csv tmp/products.csv は CSV を書き出します。
-w と -d は一致したすべての行に作用します。先に条件を確認しバックアップしてください。dump は public テーブルのデータを lil JSON に保存しますが、スキーマや索引、権限は含まれません。pg_dump の代わりではなく、PHP pgsql 拡張が必要です。
よく使う形式はローカルリファレンスにまとまっています。短縮操作は確認と小規模な変更を担当し、高度な操作では各データベースのネイティブ構文をそのまま使えます。
dump/load の形式はドライバーごとに異なります。エンジンの全機能を含む完全なバックアップが必要な場合は、サーバー側のネイティブツールを使ってください。
パスワードは非表示入力で受け取り、コマンド履歴には保存しません。可能な限り権限を限定したアカウントを利用してください。
lil の JSON ダンプはデータのみで、スキーマオブジェクトやインデックスは再作成しません。JSON 復元はトランザクションで行われ、100000 行を超えるテーブルのエクスポートやダンプは拒否されます。
-m を使わない限り、接続データは現在の PHP セッションだけに保持されます。-m [name] はプロファイルを保護された .lil.key(0600)へ明示的に保存し、-K <name> はそれを使って再接続、-k は保存済みパスワードを表示せずに一覧または詳細を確認し、-M <name> は1件削除します。kill は他のコア状態とともに .lil.key を削除します。任意保存したプロファイルにはデータベース認証情報が含まれる場合があるため、このファイルは機密として扱ってください。
用意された例をページ上でそのまま実行できます。結果は事前に生成されてブラウザに表示され、サーバーではターミナルコマンドを実行しません。
現在の互換バージョンをインストールします。全機能は Base、縮小版は Minimum を選び、すでに導入済みのモジュール更新には upgrade を使います。
Base と Minimum は同じ現在のモジュールリリースの二つのパッケージです。
ローカル参照と公開済みの全モードを含む完全パッケージをインストールします。
install postgresql縮小パッケージをインストールします。ローカルリファレンスは含まれず、
install postgresql -mこの公開済みバージョンを正確に指定してインストールします。
install postgresql -v 1.1.4upgrade が互換性を確認し、必要な場合だけブロックを置換します。
upgrade postgresqlコアや他のモジュールに触れず拡張ブロックを削除します。
install postgresql -u例はコピーできますが、サイトは実行しません。実プロジェクトではパス、権限、破壊的オプションを確認してください。
postgresql学習用の例 — 実際の接続なし
A connection is required; the status view names the server and selected database.postgresql -c localhost demo shop -n学習用の例 — 実際の接続なし
Connection example: server and database will be shown after a successful connection.postgresql -c localhost demo shop学習用の例 — 実際の接続なし
Password is requested separately; selected database: shop.postgresql -c localhost demo shop -p 5433 -n学習用の例 — 実際の接続なし
Connection example: server and database will be shown after a successful connection.postgresql -use shop学習用の例 — 実際の接続なし
Selected database: shop (requires an active connection)postgresql -l学習用の例 — 実際の接続なし
postgres
shoppostgresql -t学習用の例 — 実際の接続なし
products BASE TABLEpostgresql -s products学習用の例 — 実際の接続なし
column_name data_type
id bigint
sku text
name text
category text
price numeric
active booleanpostgresql -n products 2学習用の例 — 実際の接続なし
sku=SHOE-1 name=City shoe category=shoes price=79.9 active=True
sku=BAG-1 name=Canvas bag category=bags price=44.5 active=Truepostgresql -f products shoe 2学習用の例 — 実際の接続なし
sku=SHOE-1 name=City shoe category=shoes price=79.9 active=Truepostgresql -o products -j学習用の例 — 実際の接続なし
[
{
"sku": "SHOE-1",
"name": "City shoe",
"category": "shoes",
"price": 79.9,
"active": true
},
{
"sku": "BAG-1",
"name": "Canvas bag",
"category": "bags",
"price": 44.5,
"active": true
}
]postgresql -o products -csv tmp/products.csv学習用の例 — 実際の接続なし
Saved sandbox/tmp/products.csv (if the destination does not exist)postgresql -o products -j tmp/products.json -f学習用の例 — 実際の接続なし
Saved sandbox/tmp/products.json (replace existing file only with -f)postgresql -a products : {"sku":"NEW-1","name":"Sample","category":"test","price":5,"active":true}学習用の例 — 実際の接続なし
Inserted 1 (example with a fresh, isolated copy)postgresql -w products sku SHOE-1 : {"price":75}学習用の例 — 実際の接続なし
Updated 1 (illustrative single matching row)postgresql -d products sku SHOE-1学習用の例 — 実際の接続なし
Deleted 1 (example only; all matches would be affected)postgresql : SELECT COUNT(*) AS total FROM products学習用の例 — 実際の接続なし
total
2postgresql dump tmp/shop-pg.json学習用の例 — 実際の接続なし
Saved sandbox/tmp/shop-pg.json
Format lil-postgresql-json (logical data export, not server backup)postgresql dump tmp/shop-pg.json -f学習用の例 — 実際の接続なし
Saved sandbox/tmp/shop-pg.json
Format lil-postgresql-json (logical data export, not server backup)postgresql load db/postgresql.sql学習用の例 — 実際の接続なし
SQL/JSON import requires an existing schema; running the supplied CREATE TABLE twice causes a conflict.postgresql load tmp/shop-pg.json学習用の例 — 実際の接続なし
SQL/JSON import requires an existing schema; running the supplied CREATE TABLE twice causes a conflict.postgresql -m shop-demo学習用の例 — 実際の接続なし
Saved shop-demo (stores a sensitive profile in .lil.key)postgresql -k学習用の例 — 実際の接続なし
No saved connections (unless a profile has already been saved)postgresql -k shop-demo学習用の例 — 実際の接続なし
Saved connection not found: shop-demo (unless saved earlier)postgresql -K unknown学習用の例 — 実際の接続なし
Saved connection not found: unknownpostgresql -M unknown学習用の例 — 実際の接続なし
Saved connection not found: unknownpostgresql -e学習用の例 — 実際の接続なし
+postgresql -c localhost demo shop -p 99999 -n学習用の例 — 実際の接続なし
Invalid database portpostgresql -s missing_table学習用の例 — 実際の接続なし
Table not found: missing_tablesandbox/db/postgresql.sql例では、保護されたドキュメント用 /sandbox/ ワークスペースのファイルまたはディレクトリを使います。
CREATE TABLE products (id BIGSERIAL PRIMARY KEY, sku text UNIQUE NOT NULL, name text NOT NULL, category text NOT NULL, price numeric(10,2) NOT NULL, active boolean NOT NULL DEFAULT true);
INSERT INTO products(sku,name,category,price,active) VALUES ('SHOE-1','City shoe','shoes',79.90,true),('BAG-1','Canvas bag','bags',44.50,true);