DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: anyone have test data I could add to my database

  1. #1
    Join Date
    Oct 2002
    Location
    Washington State
    Posts
    6
    Any one have test data I could use to add to my own database
    please reply
    thank you

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    ORACLE_HOME/rdbms/admin/utlsampl.sql creates scott/tiger account for you with some sample data.


  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Code:
    CREATE TABLE XYZ (X NUMBER, Y DATE, Z VARCHAR2(100));
    
    DECLARE
       i INTEGER;
    BEGIN
       FOR i IN 1..1000 LOOP
          INSERT INTO XYZ VALUES (i, sysdate+i, to_char(i));
       END LOOP;
       COMMIT;
    END;
    /
    Jeff Hunter

  4. #4
    Join Date
    May 2002
    Posts
    2,645
    Technically, you don't need to declare i as an integer. The loop statement (for i in 1..1000) has an implicit variable declaration for i.

    SQL> create table xyz (
    2 i number,
    3 date_plus date,
    4 char_i varchar2(10));

    Table created.

    SQL> BEGIN
    2 FOR i IN 1..1000 LOOP
    3 INSERT INTO XYZ VALUES (i, sysdate+i, to_char(i));
    4 END LOOP;
    5 COMMIT;
    6 END;
    7 /

    PL/SQL procedure successfully completed.

    SQL> select count(*) from xyz;

    COUNT(*)
    ----------
    1000

  5. #5
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    While we are in the process of dissecting Jeff's suggestion, I would rather do it like:
    Code:
    INSERT INTO xyz (i, date_plus, char_i)
      SELECT object_id, created, object_name
      FROM all_objects
      WHERE ROWNUM <= 1000;
    COMMIT;
    Or if you insist that data should be populated based on sequenced numbers, you could use:
    Code:
    INSERT INTO xyz (i, date_plus, char_i)
      SELECT ROWNUM, SYSDATE+ROWNUM, TO_CHAR(ROWNUM)
      FROM all_objects
      WHERE ROWNUM <= 1000;
    COMMIT;
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  6. #6
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Geesh, you try and write a little PL/SQL humour and look what you get...
    Jeff Hunter

  7. #7
    Join Date
    May 2002
    Posts
    2,645
    You're playing to a tough audience. However, no one can follow your act because it is so good. I had to wait five months to catch you on something.

  8. #8
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    All I can say is 'I'm glad it was you in the crosshairs this time - I've definitely filled my quota this month already'

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  9. #9
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Surely, you could whip us up a package to do this, eh Chris?
    Jeff Hunter

  10. #10
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Oh no no no....

    You seem to be doing just fine on your own.

    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width