DEV Community

Frits Hoogland for YugabyteDB

Posted on

Create sample YugabyteDB table with data

I keep finding myself looking around for a quick and convenient way to to create a table populated with data.
(the datasets are described as being free to use for testing)

Download 100,000 rows dataset.

curl -L https://github.com/datablist/sample-csv-files/raw/main/files/people/people-100000.zip > people-100000.zip
unzip people-100000.zip
Enter fullscreen mode Exit fullscreen mode

Download 1,000,000 rows dataset.

curl -L https://github.com/datablist/sample-csv-files/raw/main/files/people/people-1000000.zip > people-1000000.zip
unzip people-1000000.zip
Enter fullscreen mode Exit fullscreen mode

Create table and import data into YCQL (Cassandra compatible)

create keyspace sample;
use sample;
create table sample_data
(
index int primary key,
user_id text,
first_name text,
last_name text,
sex text,
email text,
phone text,
date_of_birth text,
job_title text
);
--copy sample_data from 'people-100000.csv' with header=true;
copy sample_data from 'people-1000000.csv' with header=true;
Enter fullscreen mode Exit fullscreen mode

Create table and import data into YSQL (PostgreSQL compatible)

create table sample_data
(
index int primary key,
user_id text,
first_name text,
last_name text,
sex text,
email text,
phone text,
date_of_birth text,
job_title text
);
--\copy sample_data from 'people-100000.csv' csv header;
\copy sample_data from 'people-1000000.csv' csv header;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)