I am currently using CTAS to create and populate a table with random values.
I want to change the CTAS to add a new column work_days VARCHAR2(7). How can ALL 7 bytes of this new column, for all rows, each be randomly populated with either a 'Y' or 'N'?
Example:
YNYYYNY
CREATE TABLE employees AS
SELECT level AS employee_id,
CASE round(dbms_random.value(1,20))
WHEN 1 THEN 'Albert'
WHEN 2 THEN 'Tom'
WHEN 3 THEN 'Anna'
WHEN 4 THEN 'Ty'
WHEN 5 THEN 'Andy'
WHEN 6 THEN 'Thomas'
WHEN 7 THEN 'Alan'
WHEN 8 THEN 'Tara'
WHEN 9 THEN 'Cheryl'
WHEN 10 THEN 'Ed'
WHEN 11 THEN 'Steve'
WHEN 12 THEN 'Mel'
WHEN 13 THEN 'Micheal'
WHEN 14 THEN 'Ron'
WHEN 15 THEN 'Donald'
WHEN 16 THEN 'Donny'
WHEN 17 THEN 'Racheal'
WHEN 18 THEN 'Debbie'
WHEN 19 THEN 'Madison'
WHEN 20 THEN 'Danny'
END AS first_name,
CASE round(dbms_random.value(1,20))
WHEN 1 THEN 'Andrews'
WHEN 2 THEN 'Thorton'
WHEN 3 THEN 'Smith'
WHEN 4 THEN 'Jones'
WHEN 5 THEN 'Ott'
WHEN 6 THEN 'Stevens'
WHEN 7 THEN 'Feldman'
WHEN 8 THEN 'Stein'
WHEN 9 THEN 'Ross'
WHEN 10 THEN 'Eden'
WHEN 11 THEN 'Saltzman'
WHEN 12 THEN 'Kramer'
WHEN 13 THEN 'Monroe'
WHEN 14 THEN 'Hanks'
WHEN 15 THEN 'Dunn'
WHEN 16 THEN 'Dunbar'
WHEN 17 THEN 'Rucker'
WHEN 18 THEN 'Silverberg'
WHEN 19 THEN 'Daniels'
WHEN 20 THEN 'Kahn'
END AS last_name,
dbms_random.string('X', dbms_random.value(5, 10)) AS card_num
FROM dual
CONNECT BY level <= 50;
Aucun commentaire:
Enregistrer un commentaire