본문 바로가기
Work/DataBase

[DB] DBMS별 대용량의 Test Table 만드는법

-- ORACLE
CREATE TABLE test_large
    AS
      SELECT ROWNUM                    AS id
      ,      MOD(ROWNUM,100)            AS grp  --2000개씩 그룹핑
      ,      DBMS_RANDOM.STRING('u',5)  AS val  --랜덤 문자5개
      ,      DBMS_RANDOM.STRING('u',30) AS pad  --랜덤문자 30개
      FROM  dual
      CONNECT BY ROWNUM <= 2000000  --200만건 만들자...
      
      
      
-- POSTGRESQL
CREATE TABLE test_large AS 
    SELECT
        gs as idx,
        '테스트 문자열' || gs AS test_string,
        md5(random()::text) AS random_string
    FROM
        generate_series(1, 2000000) AS gs;