postgresql

  1. まずpostgresqlになってみる
    amori@popowa:~$ sudo su postgres
  2. DBを作ってみる
    postgres@popowa:/home/amori$ createdb test_db_1
    CREATE DATABASE
    #出来た
  3. 次はユーザを追加してみる
    postgres@popowa:/home/amori$ createuser test_db_user
    Shall the new user be allowed to create databases? (y/n) n
    Shall the new user be allowed to create more new users? (y/n) n
    CREATE USER
    #出来た
  4. DBを立ち上げてみる
    postgres@popowa:/home/amori$ psql test_db_1
    Welcome to psql 7.4.7, the PostgreSQL interactive terminal.
    
    Type:  \copyright for distribution terms
           \h for help with SQL commands
           \? for help on internal slash commands
           \g or terminate with semicolon to execute query
           \q to quit
    
    test_db_1=#
  5. tableを作ってみる
    test=# create table weather(
    test(# city varchar(80),
    test(# temp_lo int,
    test(# temp_hi int,
    test(# prcp real,
    test(# date date
    test(# );
    CREATE TABLE
  • DB削除する
    dropdb {db name}
  • version test=# select version();
    version
    PostgreSQL 7.4.7 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc (GCC) 3.3.5 (Debian 1:3.3.5-12)
    (1 row)

Last-modified: 2012-03-12 (月) 17:06:03 (166d)