Base de datos db2

Solo disponible en BuenasTareas
  • Páginas : 5 (1229 palabras )
  • Descarga(s) : 0
  • Publicado : 23 de agosto de 2012
Leer documento completo
Vista previa del texto
MODO CONSOLA

db2inst1@db2rules:~> db2start
db2inst1@db2rules:~> db2 create db Roberto
db2inst1@db2rules:~> db2 connect to Roberto
db2inst1@db2rules:~> db2 "CREATE TABLE registro (empid INTEGER, name CHAR(50), dept INTEGER)"

db2inst1@db2rules:~> db2 describe table registro

Data type Column
Column nameschema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- -----
EMPID SYSIBM INTEGER 4 0 Yes
NAME SYSIBM CHARACTER 50 0 Yes
DEPT SYSIBM INTEGER 4 0 Yes3 record(s) selected.

db2inst1@db2rules:~> db2 "alter table registro alter column dept set data type char(9)"

db2inst1@db2rules:~> db2 describe table registro

Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ----------------------------- ----- -----
EMPID SYSIBM INTEGER 4 0 Yes
NAME SYSIBM CHARACTER 50 0 Yes
DEPT SYSIBM CHARACTER 9 0 Yes
3 record(s) selected.

db2inst1@db2rules:~> db2 "INSERT INTO registro (EMPID, NAME, DEPT) VALUES (1, 'Adam', 'A01 '), (2,'John', 'B01'), (3, 'Peter', 'B01'), (4, 'William', 'A01')"

db2inst1@db2rules:~> db2 "select * from registro "

EMPID NAME DEPT
----------- -------------------------------------------------- ---------
1 Adam A01
2 JohnB01
3 Peter B01
4 William A01
4 record(s) selected.

db2inst1@db2rules:~> db2 "update registro set dept='A01' where
name='Peter'"

db2inst1@db2rules:~> db2 "select * from registro "

EMPID NAMEDEPT
----------- -------------------------------------------------- ---------
1 Adam A01
2 John B01
3 Peter A01
4 William A01
4record(s) selected.

db2inst1@db2rules:~> db2 "delete registro where name='William'"

db2inst1@db2rules:~> db2 "select * from registro”

EMPID NAME DEPT
----------- -------------------------------------------------- ---------
1 Adam A01
2 JohnB01
3 Peter A01
3 record(s) selected.

db2inst1@db2rules:~> db2 list tables

Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
REGISTRO DB2INST1 T2010-03-30-16.37.05.046385
1 record(s) selected.

db2inst1@db2rules:~> db2 CREATE SCHEMA myschema AUTHORIZATION db2inst1

db2inst1@db2rules:~> db2 select schemaname from syscat.schemata

SCHEMANAME
-----------------------------------------------------------------------
DB2INST1
MYSCHEMA
NULLID
SQLJ
SYSCAT
SYSFUN
SYSIBM
SYSIBMADM
SYSIBMINTERNAL
SYSIBMTS
SYSPROC
SYSPUBLIC
SYSSTAT
SYSTOOLS...
tracking img