-
Any one have test data I could use to add to my own database
please reply
thank you
-
ORACLE_HOME/rdbms/admin/utlsampl.sql creates scott/tiger account for you with some sample data.
-
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
-
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
-
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?
-
Geesh, you try and write a little PL/SQL humour and look what you get...
Jeff Hunter
-
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.
-
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
-
Surely, you could whip us up a package to do this, eh Chris?
Jeff Hunter
-
Oh no no no....
You seem to be doing just fine on your own.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|