I have below table with schema , i want to generate some 10K or 20K test data and i want the test data values as per related column data type , anyone can you please suggest on this , in this table i want the test data for ID unique values for each row , but am fine with migration_id values can be same for more than one row
CREATE TABLE student_services ( id uuid NOT NULL, mobile_type VARCHAR(10) NOT null, migration_id uuid NOT NULL, service_type text NOT NULL, s_config jsonb NOT NULL, subs_id uuid NULL, expire_at timestamp NOT NULL );
i tried with some scripts but am failing to handle UUID type
2
Answers
the UUID values can be generated by using the uuid extension:
and then you can simply generate the UUID using the function
For rest of the data you can generate using any external program in java/node/python or import it from an excel/csv
If you’re using PostgreSQL 13 or above, you can use
gen_random_uuid()
to generate random UUIDs.For older version, you would need to use the
uuid-ossp
extension, as described in @vaibhav’s answer. The downside is thatCREATE EXTENSION ...
needs to be done as a database superuser first.