Netezza Cheat Sheet
Netezza Cheat Sheet
html
1
SELECT ORX.database::nvarchar(64) AS"DatabaseName",
2
case when sum(SOD.allocated_bytes)is null then 0
elseSUM(SOD.allocated_bytes)/1073741824end AS "AllocatedSpace_GB"
3
FROM _V_SYS_OBJECT_DSLICE_INFO SODINNER JOIN _V_OBJ_RELATION_XDB ORXON
ORX.objid = SOD.tblid
4
GROUP BY "DatabaseName"
5
ORDER BY "DatabaseName"
DISTRIBUTE ON RANDOM
;
-- how-to perform a simple select
WHERE
AND 1=1
ORDER BY WhereColumnName
CALL ProcName ;
EXEC ProcName ;
EXECUTE ProcName ;
BEGIN_PROC
DECLARE
StrVar varchar;
BEGIN
END;
END_PROC
; --END PROC
/*
a multi-line comment
*/
LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
BEGIN
END;
END_PROC
-- Control structure
film_genre := 'drama';
film_genre := 'comedy';
film_genre := 'action';
film_genre := 'narrative';
ELSE
film_genre := 'Uncategorized';
END IF;
;
-- how-to document a stored procedure
-- select top
group by 1,2,3
;
DROP TABLE TmpTableDuplicates
SELECT GROUPNAME,OWNER,CREATEDATE,ROWLIMIT,SESSIONTIMEOUT,
-- Query to get list of users and the groups they are in, on the box:
--Query to find the number of rows in a table without actually querying the table:
-- (Sometimes needed for some really huge tables of rowcount > 80 Billion)
CASE
END NUM_ROWS
FROM
_T_CLASS,
_T_OBJECT
WHERE
_T_OBJECT.OBJID=_T_CLASS.OID AND
--Query to check if any of the SPU's are running slower than the rest:
-- (This actually gives the read-write speed of each SPU that is online)
FROM
_VT_DISK_TIMING
ORDER BY 2;
--- HOW-TO GET THE LIST OF TABLES AND THIER SKEW AND SIZE:
SELECT TABLENAME,OBJTYPE,OWNER,CREATEDATE,USED_BYTES,SKEW
FROM _V_TABLE_ONLY_STORAGE_STAT
ORDER BY TABLENAME;
FROM DatabaseNameSource.SchemaNameSource.TableNameSource
);
-- _V_USER : The user view gives information about the users in the netezza system.
-- _V_TABLE: The table view contains the list of tables created in the netezza
performance system.
-- _V_RELATION_COLUMN: The relation column system catalog view contains the columns
available in a table.
-- _V_TABLE_INDEX: This system catalog contains the information about the indexes
created on table. netezza does not support creating indexes on a table as of now.
-- _V_OBJECTS: Lists the different objects like tables, view, functions etc
available in the netezza.
/*
\l - list of databases
\l - list databases