DB2 - Exemplos simples - Reference code - Código de referência



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

DB2 - Exemplos simples - Reference code - Código de referência




  1. SELECT - Fetch specific column(s) from a table
    SELECT - Buscar coluna (s) específica (s) de uma tabela

  2.     SELECT column_name1
        ,      column_name2, ...
          FROM table_name;

  3. SELECT - Fetch all columns from a table
    SELECT - busca todas as colunas de uma tabela

  4.     SELECT *
          FROM table_name;

  5. SELECT DISTINCT - Selects only the DISTINCT column values from the table.
    SELECT DISTINCT - Seleciona apenas os valores da coluna DISTINCT da tabela

  6.     SELECT DISTINCT column_name1
          FROM table_name;

  7. SELECT COUNT(DISTINCT) - lists the number of different (distinct) value in the table column.
    COUNT (DISTINCT) - lista o número de valores diferentes na coluna da tabela

  8.     SELECT COUNT(DISTINCT column_name)
          FROM table_name;

  9. WHERE - Fetch records based on text field(s) in where clause
    WHERE - Buscar registros com base no (s) campo (s) de texto na cláusula where

  10.     SELECT * 
          FROM table_name
         WHERE column_name = 'text_value';

  11. WHERE - Fetch records based on numeric field(s) in where clause
    WHERE - Buscar registros com base em campo (s) numérico (s) na cláusula where

  12.     SELECT * 
          FROM table_name
         WHERE column_name = numeric_value;

  13. AND operator in WHERE clause
    Operador AND na cláusula WHERE

  14.     SELECT * 
          FROM table_name
         WHERE column_name1 = numeric_value
           AND column_name2 = numeric_value;

  15. OR operator in WHERE clause
    Operador OR na cláusula WHERE

  16.     SELECT * 
          FROM table_name
         WHERE column_name1 = numeric_value
            OR column_name2 = numeric_value;

  17. NOT operator in WHERE clause
    Operador NOT na cláusula WHERE

  18.     SELECT * 
          FROM table_name
         WHERE NOT column_name = numeric_value;

  19. AND/OR operator in WHERE clause
    Operador AND/OR na cláusula WHERE

  20.     SELECT * 
          FROM table_name
         WHERE column_name1 = numeric_value1
           AND (column_name2 = numeric_value2
            OR column_name3 = numeric_value3);

  21. ORDER BY - Sort the record in ascending order
    ORDER BY - Classifica o registro em ordem crescente

  22.     SELECT * 
          FROM table_name
         ORDER BY column_name;

  23. ORDER BY - Sort the record in descending order
    ORDER BY - Classifica o registro em ordem decrescente

  24.     SELECT * 
          FROM table_name
         ORDER BY column_name DESC;

  25. ORDER BY - Sort the record in ascending order by multiple columns
    ORDER BY - Classifica o registro em ordem crescente por várias colunas

  26.     SELECT * FROM table_name
         ORDER BY column_name1
         ,        column_name2;

  27. ORDER BY - Sort the record in descending order by multiple columns
    ORDER BY - Classifica o registro em ordem decrescente por várias colunas

  28.     SELECT * 
          FROM table_name
         ORDER BY column_name1 DESC
         ,        column_name2 DESC;

  29. INSERT INTO - Insert data into all columns in a row
    INSERT INTO - Insere dados em todas as colunas em uma linha

  30. 
    INSERT INTO table_name
         VALUES ('text_value1'
         ,       'text_value2'
         ,        numeric_value
         ,       'text_value3');
    

  31. INSERT INTO - Insert data into specific column in a row
    INSERT INTO - Insere dados em uma coluna específica em uma linha

  32.     INSERT INTO table_name (column_name1
        ,                       column_name2
        ,                       column_name3)
             VALUES (numeric_value1
        ,            numeric_value2
        ,           'text_value3');

  33. IS NULL - Fetch null column rows in a table
    IS NULL - busca linhas de colunas nulas em uma tabela

  34.     SELECT *
          FROM table_name
         WHERE column_name IS NULL;

  35. IS NOT NULL - Fetch not null column rows in a table
    IS NOT NULL - busca linhas de coluna não nulas em uma tabela

  36.     SELECT *
          FROM table_name
         WHERE column_name IS NOT NULL;

  37. UPDATE - Update single or multiple row in a table using where clause
    UPDATE - Atualizar linha única ou múltipla em uma tabela usando a cláusula Where

  38.     UPDATE table_name
           SET column_name1 = value1
           ,   column_name2 = value2
         WHERE column_name  = value;

  39. UPDATE - Update all row in a table
    UPDATE - Atualizar todas as linhas em uma tabela

  40.     UPDATE table_name
           SET column_name = value;

  41. DELETE - Delete single or multiple rows in a table
    DELETE - Excluir uma ou várias linhas em uma tabela

  42.     DELETE FROM table_name
         WHERE column_name = 'text_value';

  43. DELETE - Delete all row in a table
    DELETE - Exclui todas as linhas de uma tabela

  44.     DELETE FROM table_name;


© Copyright www.ibmmainframer.com.