Oracle Vs Nucleus Vs Sybase IQ Vs Netezza
Oracle Vs Nucleus Vs Sybase IQ Vs Netezza
Oracle Vs Nucleus Vs Sybase IQ Vs Netezza
com
Page 1 of 18
www.enselsoftware.com
Page 2 of 18
www.enselsoftware.com
Page 3 of 18
www.enselsoftware.com
Page 4 of 18
www.enselsoftware.com
shutdown immediate
keep change [saved
permanently with
entry point]
Running an SQL In SQL Plus In Nisqlm
file within SQL SQL>@filename.sql SQL> .run
prompt filename.sql
To rename a table RENAME TABLE ALTER TABLE ALTER TABLE
current_name TO schema.old_name current_name RENAME
new_name RENAME new_name TO new_name
Page 5 of 18
www.enselsoftware.com
Unloading (i.e. extracting data) a table (not all columns) using ndlm
export @/usr/users/cp_dev/sbasak/nuc_extract.txt
NULL ""
RECORD
{
CAMPAIGN_ID *|
CAMPAIGN_NAME *\n
}
select campaign_id, campaign_name from cas.campaign_history_lookup with sample of 10;
}
If you are unloading all fields you can use “select *” also.
import @/MHDS2/dev/ltsbcp/cas/data/mfs/partitions/mfs_4way_0/load/GI_REP_FORECAST_R2L.dat
@/MHDS2/dev/ltsbcp/cas/data/mfs/partitions/mfs_4way_1/load/GI_REP_FORECAST_R2L.dat
@/MHDS2/dev/ltsbcp/cas/data/mfs/partitions/mfs_4way_2/load/GI_REP_FORECAST_R2L.dat
@/MHDS2/dev/ltsbcp/cas/data/mfs/partitions/mfs_4way_3/load/GI_REP_FORECAST_R2L.dat
NULL ""
RECORD
{
Page 6 of 18
www.enselsoftware.com
product *\t
media *\t
date_sequence *\t
cum_perc_total_sales *\t
sum_sale_ind_keys *\t
sum_sale_ind *\t
cum_sales_total *\n
}
CAS.GI_REP_FORECAST
{
product product
media media
date_sequence date_sequence
cum_perc_total_sales cum_perc_total_sales
sum_sale_ind sum_sale_ind
cum_sales_total cum_sales_total
}
}
-- DESCRIBE A TABLE
SELECT
C.COLNO
,C.NAME
,D.TYPE
,C.LENGTH
,C.DOMAINID
,DN.NAME
Page 7 of 18
www.enselsoftware.com
FROM
SYSTEM.TABLES T
JOIN SYSTEM.COLUMNS C ON T.TABLEID = C.TABLEID
JOIN SYSTEM.DATATYPES D ON C.DATATYPE = D.DATATYPE
JOIN SYSTEM.DOMAINS DN ON C.DOMAINID = DN.DOMAINID
WHERE
T.TABLEID = (SELECT TABLEID FROM SYSTEM.TABLES WHERE NAME = UPPER('CAMPAIGN_HISTORY_LOOKUP'))
AND T.SCHEMAID = (SELECT SCHEMAID FROM SYSTEM.SCHEMAS WHERE NAME = UPPER('CAS'))
ORDER BY 1
;
Nserv is the database engine. There can be only one active nserv connection to any database at
any time. If you try to log in to database with another nserv session, the previous connection
will be automatically disconnected. With nserv connection, you have unrestricted access to
database.
Page 8 of 18
www.enselsoftware.com
With Octopus connection, you can log in to database and modify data but your changes will not be
visible to other users (either nserv or another Octopus connection). With octopus, you can never
make any permanent changes to the database. The advantage of using octopus is that, several
users can use their own what-if scenarios with their own data – without actually affecting other
users (as they won’t see this data). As a result, COMMIT WORK statement will work only on nserv
connection and not on octopus connection.
select
t.table_id
,t.table_name
,t.table_type
,c.column_id
,c.column_name
,c.column_type
,c.pkey
,c.nulls
,c.width
,d.domain_name
,t.view_def
from
sys.systable t
join sys.syscolumn c on t.table_id = c.table_id
join sys.sysdomain d on c.domain_id = d.domain_id
where
t.table_name = upper('experian_omnibase')
and user_name(creator) = 'CAS'
To see what SQLs are currently running on database, run this command
Sp_iqcontext
Page 9 of 18
www.enselsoftware.com
sp_iqstatus
Log in to database as (either from database server of from client box – if available)
isql -S lbgw_qa -U DBA -P SQL
Sybase IQ architecture
Page 10 of 18
www.enselsoftware.com
IQ Store = Oracle’s logical tablespace which contains physical data file(s). In Sybase IQ, the
data are actually indexes.
Catalog store = Sybase IQ tables are logically defined here (i.e. table metadata) somewhat
similar to Oracle’s System/Sysaux tablespace. It contains system tables and all stored
procedures. Only one catalog store per database.
Page 11 of 18
www.enselsoftware.com
Sybase IQ load file (load data from database – like SQL Loader configuration file)
Page 12 of 18
www.enselsoftware.com
Note: Unlike most loaders where each field in the file is separated by a field delimiter except
the last field which just has the row delimiter, Sybase IQ loader expects the last field to also
have the field delimiter and then followed by the row delimiter. The Unix “tr –d” command can be
used to remove newline characters from load files.
This sample stored procedure will create a procedure which will count records of all tables
under a given schema (user). This command can be run at isql prompt.
Page 13 of 18
www.enselsoftware.com
In Sybase, if you get “Database page size error” when trying to issue “select * from tablename”,
execute this before “select * from tablename” command.
Page 14 of 18
www.enselsoftware.com
The IQ doesn’t have queues for requests of changing its objects, like other RDBMSes (SQL Server,
Oracle, ASE, ASA, MYSQL, DB2, etc) do. Therefore, every update/delete/insert/alter/create index
to a table/view/procedure locks the object and the second transaction that’s trying to make a
change, getting an error message. That’s why the IQ is not the right database to make
transactions. The cache mechanism needs a database that gets many transactions from the
application and can handle many update/delete/insert transactions. Therefore it uses ASA
(Adaptive Server Anywhere) as a transactional database to get the changes from the application
and the cache mechanism copy the new records to the IQ.
Netezza Examples
Show time –
dbname(user)=> select now();
Describe a table
Loading data to a Netezza table from an external text file (similar to SQL Loader)
100
200
300
Log on to nzsql (eg. nzsql lbcccms_dev cms_dev L10yds01 – it may be necessary to log on from same box where
Netezza is installed or do an rsh/ssh if possible)
Page 15 of 18
www.enselsoftware.com
If input data is tab delimited, then the tab DELIMITER ' ' character should be inserted from
Unix prompt by pressing tab key(copy-paste from Windows won’t work)!
select
t.tablename
,t.objtype
,t.owner
,c.attname
,c.format_type
Page 16 of 18
www.enselsoftware.com
from
_v_table t
join _v_relation_column c on t.objid = c.objid
where
t.tablename = lower('gi_uss')
execute immediate 'select count(*) into val2 from sys.systable where table_name = ''summary_table'' and
user_name(creator) = ''' || @p_user || '''' ;
if val2 = 1 then -- table exists, so truncate
execute immediate 'truncate table ' || @p_user || '.summary_table;';
else -- no table, so create
execute immediate '' ||
'CREATE TABLE summary_table (' ||
' "table_name" char(128) NOT NULL DEFAULT NULL,' ||
' "table_type" char(10) NOT NULL DEFAULT NULL,' ||
' "column_id" unsigned int NOT NULL DEFAULT NULL,' ||
' "column_name" char(128) NOT NULL DEFAULT NULL,' ||
' "column_type" char(1) NOT NULL DEFAULT NULL,' ||
' "pkey" char(1) NOT NULL DEFAULT NULL,' ||
' "nulls" char(1) NOT NULL DEFAULT NULL,' ||
' "width" smallint NOT NULL DEFAULT NULL,' ||
' "domain_name" char(128) NOT NULL DEFAULT NULL)';
end if;
Page 17 of 18
www.enselsoftware.com
commit work;
end
go
--------------------------------------------------------------------------------
exec get_tables_structure('lp_train_data');
go
Page 18 of 18