PoT.0121.01-DB Server Primer
PoT.0121.01-DB Server Primer
PoT.0121.01-DB Server Primer
Contents
APACHE CASSANDRA DATABASE (V2.0.12) ............................................................................................................................. 3
APACHE COUCHDB (V1.6.1) ........................................................................................................................................................ 4
IBM DB2 (10.5.0.6 (FP6 - ADVANCED ENTERPRISE SERVER EDITION (AESE)) .................................................................... 5
EMC/VMWARE PIVOTAL GREENPLUM DATABASE (V4.2.2.4).................................................................................................. 6
IBM INFORMIX (V12.1) ................................................................................................................................................................... 7
10GEN MONGODB (V2.6.7) ........................................................................................................................................................... 8
ORACLE MYSQL (V5.6.22) – PART OF LAMP (LINUX, APACHE, MYSQL, PHP / PERL / PYTHON) ........................................ 9
ORACLE XE (V11.2.0.2.0) ............................................................................................................................................................ 10
POSTGRESQL (V9.4.0) ................................................................................................................................................................ 11
SYBASE ASE (V15.7) ................................................................................................................................................................... 12
Database Commands
1) Database Server start / stop / restart / status (as root user):
service cassandra start / stop / restart / status
2) Connect:
cqlsh -u cassandra -p cassandra
cassandra-cli -u cassandra -pw cassandra
3) Show users:
list users;
4) Create database:
create keyspace demodb with replication = {'class' : 'SimpleStrategy', 'replication_factor': 3};
5) Show databases:
describe keyspaces;
6) Use database:
use demodb;
7) Show tables:
describe tables;
8) Create table:
create table creditcard (custid int, fname varchar, lname varchar, ccn varchar, primary key (custid));
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444');
10) Select table:
select * from creditcard;
11) Alter table:
alter table creditcard add address varchar;
12) Drop table:
drop table creditcard;
13) Exit database:
exit / quit
Database Commands
1) Database Server start / stop / restart / status (as root user):
service couchdb start / stop / restart / status
2) Connect:
http://10.10.9.56:5984/_utils/ (Futon)
curl http://127.0.0.1:5984/
3) Show users:
curl -s http://127.0.0.1:5984/_users/_all_docs
4) Create database:
curl -X PUT http://127.0.0.1:5984/demodb
5) Show databases:
curl -X GET http://127.0.0.1:5984/_all_dbs
6) Use database:
curl http://127.0.0.1:5984/demodb
7) Show documents:
curl -X GET http://127.0.0.1:5984/demodb/_all_docs
8) Create document:
http://10.10.9.56:5984/_utils/ (Futon)
9) Insert data:
http://10.10.9.56:5984/_utils/ (Futon)
10) Select document:
http://10.10.9.56:5984/_utils/ (Futon)
11) Alter table:
http://10.10.9.56:5984/_utils/ (Futon)
12) Drop table:
http://10.10.9.56:5984/_utils/ (Futon)
13) Exit database:
Exit browser
Database Commands
1) Database Server start / stop / restart / status (as root user):
service IBMdb2 start / stop / restart / status
2) Connect:
db2
3) Show users:
select grantee from syscat.dbauth
4) Create database:
create database sample
5) Show databases:
list database directory
6) Use database:
connect to sample
7) Show tables:
list tables
8) Create table:
create table creditcard (custid integer not null, fname varchar(25), lname varchar(25), ccn varchar(25),
primary key (custid))
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444')
10) Select table:
select * from creditcard;
11) Alter table:
alter table creditcard add address varchar(50)
12) Drop table:
drop table creditcard
13) Exit database:
quit
Database Commands
1) Database Server start / stop / restart (as root user):
service greenplum start / stop / restart
2) Connect:
psql -U gpadmin
3) Show users:
select rolname from pg_roles where rolcanlogin is true;
4) Create database (gpadmin database):
create database demodb \g
5) Show databases:
\l
6) Use database:
\c gpadmin
7) Show tables:
\dt
8) Create table:
create table creditcard (custid integer not null, fname varchar, lname varchar, ccn varchar, primary key
(custid)) \g
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444') \g
10) Select table:
select * from creditcard \g
11) Alter table:
alter table creditcard add address varchar \g
12) Drop table:
drop table creditcard \g
13) Exit database:
\q
Database Commands
1) Database Server start / stop / restart / status (as root user):
service informix start / stop / restart / status
2) Connect (Menu Driven Client):
dbaccess
3) Show users:
select * from sysusers
4) Create database:
Database->Create-><Database Name>-><Dbspace>-><Choose Dbspace>->Exit->Create-new-database
5) Show databases:
Database->Select-><List of databases>
6) Use database:
Database->Select->stores_demo
7) Show tables:
select tabname from systables
8) Create table:
Table->stores_demo->Create->creditcard->Add->Add-><Enter>->Exit->Build-new-table->Exit->Commit
9) Insert data:
Table->Alter->creditcard->Add->Add-><Enter>->Exit->Build-new-table->Exit->Commit
10) Select table:
Query-language->New->Type ‘select * from orders’-><ESC>->Run
11) Alter table:
Table->Alter->creditcard->Add->Add-><Enter>->Exit->Build-new-table->Exit->Commit
12) Drop table:
Table->Drop->creditcard->Exit->Commit
13) Exit database:
Exit
Database Commands
1) Database Server start / stop / restart / status (as root user):
service mongod start / stop / restart / status
2) Connect (admin database):
mongo osprey/admin -u mongo -p guardium
3) Show users:
show users
4) Create database (Implicitly created on first reference):
use <new database name>
5) Show databases:
show dbs
6) Use database:
var mydb = connect('osprey/admin')
7) Show tables:
show tables
8) Create table (This command or implicitly created on first insert):
db.createCollection("creditcard")
9) Insert data:
db.creditcard.insert ({custid: 104, fname: "jane", lname: "smith", ccn: "1111222233334444"})
10) Select table:
db.creditcard.find()
11) Alter table:
db.creditcard.update ({}, { $set: { address: "123 Parkway"}})
12) Drop table:
db.creditcard.drop()
13) Exit database:
exit
Database Commands
1) Database Server start / stop / restart / status (as root user):
service mysql start / stop / restart / status
2) Connect:
mysql -uroot -pguardium mysql
3) Show users:
select user from mysql.user;
4) Create database:
create database demodb;
5) Show databases:
show databases;
6) Use database:
use mysql;
7) Show tables:
show tables;
8) Create table:
create table creditcard (custid int, fname varchar(25), lname varchar(25), ccn varchar(16), primary key
(custid));
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444');
10) Select table:
select * from creditcard;
11) Alter table:
alter table creditcard add address varchar(50);
12) Drop table:
drop table creditcard;
13) Exit database:
exit / quit / \q
Oracle XE (v11.2.0.2.0)
Website: www.oracle.com/us/products/database/overview/index.html
Documentation: www.oracle.com/pls/db121/homepage
OS User / password: oracle / guardium
DB User / password: system / guardium
DB Install Path: /u01/app/oracle/product/11.2.0/xe
DB Storage Path: /u01/app/oracle/oradata/XE
Executable: sqlplus
Database Commands
1) Database Server start / stop / restart / status (as root user):
service oracle-xe start / stop / restart / status
2) Connect (Default is XE):
sqlplus system/guardium
3) Show users:
select * from all_users
4) Create database (Requires new instance specification, and configuration file after shutdown):
shutdown;
startup nomount;
create database demodb;
5) Show databases:
select name from v$database; / select instance_name from v$instance;
6) Use database:
N/A – based upon SID when Logging on;
7) Show tables:
select table_name from dba_tables; / select table_name from user_tables; / select table_name from
all_tables;
8) Create table:
create table creditcard (custid int, fname varchar(25), lname varchar(25), ccn varchar(16), primary key
(custid));
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444');
10) Select table:
select * from creditcard;
11) Alter table:
alter table creditcard add address varchar(50);
12) Drop table:
drop table creditcard;
13) Exit database:
exit / quit
PostgreSQL (v9.4.0)
Website: www.postgresql.org
Documentation: www.postgresql.org/docs/9.4/static/index.html
OS User / password: postgres / guardium
DB User / password: postgres
DB Install Path: /usr/pgsql-9.4
DB Storage Path: /var/lib/pgsql/9.4/data
Executable: psql
Database Commands
1) Database Server start / stop / restart / status (as root user):
service postgresql-9.4 start / stop / restart / status
2) Connect:
psql -U postgres
3) Show users:
select rolname from pg_roles where rolcanlogin is true;
4) Create database (postgres database):
create database postgres \g
5) Show databases:
\l
6) Use database:
\c postgres
7) Show tables:
\dt
8) Create table:
create table creditcard (custid integer not null, fname varchar, lname varchar, ccn varchar, primary key
(custid)) \g
9) Insert data:
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444') \g
10) Select table:
select * from creditcard \g
11) Alter table:
alter table creditcard add address varchar \g
12) Drop table:
drop table creditcard \g
13) Exit database:
\q
Database Commands
1) Database Server start / stop / restart / status (as root user):
service sybase start / stop / restart / status
2) Connect (Default is XE):
isql -S OSPREY -U sa -P guardium
3) Show users (Type "go" to execute all commands):
select name as user_name from sysusers / select name from master.dbo.sysdatabases
4) Create database:
Create database demodb
5) Show databases (Type "go" to execute all commands):
sp_helpdb
6) Use database (Type "go" to execute all commands):
use master
7) Show tables (Type "go" to execute all commands):
select name from sysobjects where type = 'U' / sp_tables
8) Create table (Type "go" to execute all commands):
create table creditcard (custid int, fname varchar, lname varchar, ccn varchar, primary key (custid))
9) Insert data (Type "go" to execute all commands):
insert into creditcard (custid, fname, lname, ccn) values (104, 'jane', 'smith','1111222233334444')
10) Select table (Type "go" to execute all commands):
select * from creditcard
11) Alter table (Type "go" to execute all commands):
alter table creditcard add address varchar
12) Drop table (Type "go" to execute all commands):
drop table creditcard;
13) Exit database:
exit / quit