Posts

Showing posts from April, 2020

Search the keywords from all files in UNIX

find . -iname "*.*" | xargs grep -i "KeyWord" 

Teradata: Split String into multiple columns and Vice Versa

Teradata: Split String into multiple columns and Vice Versa There are table functions available which Split strings into multiple columns or concat multiple columns into single string/column using delimiter character/s. CSVLD (Comma-Separated Value Data Loading) CSV (Comma-Separated Value Data Unloading)

Duplicate identification query in Teradata

SELECT * FROM student QUALIFY count() over (partition by id,name )>1;

Database Size : Calculation in Teradata

SELECT DatabaseNameI, PermSpace, SpoolSpace, TempSpace,CreateTimeStamp FROM DBC.DBase WHERE DatabaseNameI = '[databasename]'; Permanent Space: Permanent space is the maximum amount of space allocated to the user/database to hold data rows. Perm space is used for database object (permanent tables, indexes etc) creation and to hold their data. The amount of permanent space is divided among the number of AMPs.Whenever per AMP limit exceeds the allocated space of AMP, 'No more room in database' error message is generated. Spool Space: Spool space is the unused permanent space which is used by the system to keep the intermediate results of the SQL query. Users without spool space cannot execute any query. Data is active up to the current session only. Spool space is divided among the number of AMPs. Whenever per AMP limit exceeds the allocated space, the user will get a spool space error. Temporary Space: Temporary space is the unused permanent space whic...

User Access details in teradata

 SELECT A.ROLENAME, A.GRANTEE AS USER_ID, A.GRANTOR AS ADMIN_ID, B.DATABASENAME, B.TABLENAME, B.GRANTORNAME, B.ACCESSRIGHT FROM    DBC.ROLEMEMBERS A JOIN    DBC.ALLROLERIGHTS B ON  A.ROLENAME = B.ROLENAME WHERE  GRANTEE= 'UserId' GROUP BY 1,2,3,4,5,6,7 ORDER BY 2,1,6;

The difference between SET and MULTISET tables is?

The difference between SET and MULTISET tables is? SET tables  – SET tables did not allow duplicate values in the table. If not specified in the DDL of the table then Teradata will create table as default SET. A SET table force Teradata to check for the duplicate rows every time a new row is  inserted  or  updated  in the table. This is an overhead on the resource if we need to insert massive amount of rows. MULTISET tables  – MULTISET tables allow duplicate values in table. Remember that SET table causes an additional overhead of checking for the duplicate records. So we need to follow few points to save Teradata from this additional overhead. ·      If you are using any  GROUP BY  or  QUALIFY  statement on the source table then it’s highly recommended to define target table as MULTISET. As GROUP BY and QUALIFY will remove the duplicate records from the source. · ...