Automated Generate ID

Using Auto Generate Mapper with MyBatis. Case: First time inserting a record, that inserted record ID needed for another transaction. Use this SQL: <INSERT id = “insert” parameterType = “com.fikri.model.User”> <selectKey keyProperty = “id” resultType = “java.lang.Long” ORDER = “AFTER”> SELECT SEQ_USER.CURRVAL FROM DUAL </selectKey>……..</INSERT>   Simplified version:   <INSERT id = “insert” parameterType =… Read more »

Clone a Table

You want to make a temporary (buffer) table which had a same structure and data with original, use this SQL: CREATE TABLE xyz_new AS SELECT * FROM xyz; xyz_new is a temporary (buffer) table; xyz is original table. If you want to clone table’s structure without original data, use this SQL: CREATE TABLE xyz_new AS SELECT *… Read more »

Drop All (For Testing Purpose)

Clean up your mess with following command SELECT ‘drop table ‘ || table_name || ‘ cascade constraints;’ FROM user_tables Then, copy the resulting text script into sql console, and execute it. Voila!   For More VOILA!!! Clean all sequences, triggers, tables BEGIN –Bye Sequences! FOR i IN (SELECT us.sequence_name FROM USER_SEQUENCES us) LOOP EXECUTE IMMEDIATE… Read more »

Check Version

Which version My Oracle Server? Use this SQL: SELECT * FROM v$version   Result example: by

Find Duplicate Values in Table

When you want to find all duplicate value in table, use this: (adding more field to find more searching value criteria) SELECT DISTINCT NAME, EMAIL ,count(*) FROM user GROUP BY NAME, EMAIL HAVING count(*) > 1; Source: Here by

binary

Hello World!

System.out.println(“Hello World!”); Welcome to My Blog! This my first post! Gonna post more after this… 🙂 This blog’s purpose is gonna be a Wiki, contains anything related to my works or my hobbies. XD by

Latest
  • Automated Generate ID

    Using Auto Generate Mapper with MyBatis. Case: First time inserting a record, that inserted record ID needed for another transaction. Use this SQL: <INSERT id = “insert” parameterType = “com.fikri.model.User”> <selectKey keyProperty = “id” resultType = “java.lang.Long” ORDER = “AFTER”> SELECT SEQ_USER.CURRVAL FROM DUAL </selectKey>……..</INSERT>   Simplified version:   <INSERT id = “insert” parameterType =… Read more »

  • Clone a Table

    You want to make a temporary (buffer) table which had a same structure and data with original, use this SQL: CREATE TABLE xyz_new AS SELECT * FROM xyz; xyz_new is a temporary (buffer) table; xyz is original table. If you want to clone table’s structure without original data, use this SQL: CREATE TABLE xyz_new AS SELECT *… Read more »

  • Drop All (For Testing Purpose)

    Clean up your mess with following command SELECT ‘drop table ‘ || table_name || ‘ cascade constraints;’ FROM user_tables Then, copy the resulting text script into sql console, and execute it. Voila!   For More VOILA!!! Clean all sequences, triggers, tables BEGIN –Bye Sequences! FOR i IN (SELECT us.sequence_name FROM USER_SEQUENCES us) LOOP EXECUTE IMMEDIATE… Read more »

  • Check Version

    Which version My Oracle Server? Use this SQL: SELECT * FROM v$version   Result example: by

  • Find Duplicate Values in Table

    When you want to find all duplicate value in table, use this: (adding more field to find more searching value criteria) SELECT DISTINCT NAME, EMAIL ,count(*) FROM user GROUP BY NAME, EMAIL HAVING count(*) > 1; Source: Here by

  • binary

    Hello World!

    System.out.println(“Hello World!”); Welcome to My Blog! This my first post! Gonna post more after this… 🙂 This blog’s purpose is gonna be a Wiki, contains anything related to my works or my hobbies. XD by