Help us understand the problem. What is going on with this article?

DB2で個人的によく使うコマンド

More than 3 years have passed since last update.

DBの作成

db2 => CREATE DB test_db

DBの削除

db2 => DROP DB test_db

DBの一覧表示

db2 => LIST DATABASE DIRECTORY

または(上記と結果は同じ)

db2 => LIST DB DIRECTORY

DBへの接続

db2 => CONNECT TO test_table

TABLEの作成

db2 => CREATE TABLE test_table (
           id INTEGER NOT NULL,
           name VARCHAR(40) NOT NULL,
           address VARCHAR(60),
           tel VARCHAR(20),
           created_at timestamp,
           deleted_at timestamp,
           updated_at timestamp,
           PRIMARY KEY (id)
       )

TABLEの削除

db2 => DROP TABLE test_table

既存TABLE定義の変更

// カラムの追加
db2 => ALTER TABLE test_table ADD COLUMN test_column VARCHAR(256)

// カラムの削除
db2 => ALTER TABLE test_table DROP COLUMN test_column   

// 属性の付与
db2 => ALTER TABLE test_table ALTER test_column SET NOT NULL

// 属性の削除
db2 => ALTER TABLE test_table ALTER test_column DROP NOT NULL  

既存TABLE定義の確認

db2 => DESCRIBE TABLE test_table  

終わりに

毎度調べるのがめんどくさいので、個人的によく使うものをまとめました、他にもコマンドはあるので随時追加していきたいと思います!
オプションなども追加したいですね!

参考

http://db2watch.com/wiki/index.php?title=%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした