Ir al contenido principal

DB2 - Consultas de metadatos - Consultas recursivas



DB2 – consulta de metadatos

Catalog Schema: Doc original / standard name: syscat à DB2 alias: ibm

triggers
select text from sysibm.sysTRIGGERS where tbname

secuencias
select * from sysibm.syssequences where owner

stored procedure / function
select * from SYSIBM.sysroutines where owner

PK, unique constraint, FK,
select * from SYSIBM.syskeycoluse where constname
select * from SYSIBM.SYSRELS where RELNAME
select * from SYSIBM.SYSFOREIGNKEYS where relname

tables
FROM SYSIBM.SYSTABLES 
FROM SYSIBM.SYSCOLUMNS where tbname and tbcreator

Dummy
sysibm.sysdummy1

Consultas recursivas en DB2 (jerarquía jerárquicas hierarchy hierarchial recursive)

/************************************************************************/
/************************************************************************/
/******************* COMPARE THE FOLLOWING 2 QUERIES  *******************/
/************************************************************************/
/************************************************************************/
-- TOP-DOWN
with MY_HIERARCHY (MY_NODE, MY_PARENTNODE) as (
      -- non-recursive exit
      select ROOT.MY_NODE, ROOT.MY_PARENTNODE
      from THETABLE ROOT where MY_NODE='value'   -- the root node in the tree

      union all
      -- recursive loop (it needs the non-recursive part in order not to be an empty set)
      select CHILD.MY_NODE, CHILD.MY_PARENTNODE
      from MY_HIERARCHY PARENT, THETABLE CHILD
      where CHILD.MY_PARENTNODE = PARENT.MY_NODE   -- top-down join

)
select * from MY_HIERARCHY


-- BOTTOM-UP
with MY_HIERARCHY (MY_NODE, MY_PARENTNODE) as (
      -- non-recursive exit
      select LEAF.MY_NODE, LEAF.MY_PARENTNODE
      from THETABLE LEAF where MY_NODE='value'   -- the leaf node in the tree

      union all
      -- recursive loop (it needs the non-recursive part in order not to be an empty set)
      select CHILD.MY_NODE, CHILD.MY_PARENTNODE
      from MY_HIERARCHY PARENT, THETABLE CHILD
      where CHILD.MY_NODE = PARENT.MY_PARENTNODE   -- bottom-up join

)
select * from MY_HIERARCHY

Comentarios

Entradas populares de este blog

Crear proyecto de frontend con Vite, React, Tailwind, Typescript y JSX

 ¿Cómo se crea un proyecto exclusivo de frontend con Vite, React, Tailwind, Typescript y JSX? ¡Absolutamente! Entiendo que quieres la guía completa para pasar de cero a tener un proyecto de frontend moderno, vacío y listo para ser llenado con tu código. A continuación, te proporciono un archivo de guía detallada que incluye todos los comandos necesarios para inicializar el proyecto, configurar Tailwind CSS, y los pasos clave para empezar a "poblarlo". Voy a generar un documento Markdown con la guía paso a paso, incluyendo los comandos de terminal y las modificaciones esenciales a los archivos de configuración. Guía: Creación de un Proyecto Frontend Puro (Vite, React, TypeScript, Tailwind) Este documento detalla el proceso para inicializar un proyecto de frontend vacío y optimizado, utilizando Vite como empaquetador, React como librería, TypeScript para tipado y Tailwind CSS para estilizado. 1. Inicialización del Proyecto con Vite Vite es la herramienta más rápida para emp...

Tokens V2

Tokens: Programme to discover tokens, where there are not. Now available at  https://puszcza.gnu.org.ua/projects/tokens/ This is Version 2, for  version 1, go here . Synopsis: use TokensV2; sub printFile; my @FORMAT = ( ['<Message Date=".*?" Time=".*?" DateTime=".*?" SessionID=".*?"><From>(?:<User FriendlyName=".*?"/>)+</From><To>(?:<User FriendlyName=".*?"/>)+</To><Text(?: Style=".*?")?>.*?</Text></Message>',   sub {     my $fh = $_[1];     my ($d, $t, $f, $s, $T) = $_[0] =~ m|<Message Date="(.*?)" Time="(.*?)" DateTime=".*?" SessionID=".*?">(<From>(?:<User FriendlyName=".*?"/>)+</From>)<To>(?:<User FriendlyName=".*?"/>)+</To><Text(?: Style="(.*?)")?>(.*?)</Text></Message>|;     my $F = join '<br />', ...

Perl Net::LDAP::SimpleServer

Adaptaciones sobre el módulo LDAP Server para Windows (Strawberry Perl) Lista de adaptaciones (continúa más abajo): - Relajación de condiciones de bind:     - Cuenta principal (principal account)     - Validación de contraseñas Ubicación del archivo: %Strawberry_Perl%\site\lib\net\ldap\SimpleServer\ProtocolHandler.pm CPAN: http://search.cpan.org/~russoz/Net-LDAP-SimpleServer-0.0.17/lib/Net/LDAP/SimpleServer.pm Código: package Net::LDAP::SimpleServer::ProtocolHandler; use strict; use warnings; # ABSTRACT: LDAP protocol handler used with Net::LDAP::SimpleServer our $VERSION = '0.0.17';    # VERSION use Net::LDAP::Server; use base 'Net::LDAP::Server'; use fields qw(store root_dn root_pw allow_anon); use Carp; use Net::LDAP::LDIF; use Net::LDAP::Util qw{canonical_dn}; use Net::LDAP::FilterMatch; use Net::LDAP::Constant (     qw/LDAP_SUCCESS LDAP_AUTH_UNKNOWN LDAP_INVALID_CREDENTIALS/,   ...