0% found this document useful (0 votes)
147 views5 pages

Mysql Queries

The document discusses creating and querying tables in MySQL. It provides the SQL commands to create three tables: "users", "ads", and "served_ads". It also includes commands to load data from a CSV file into the "served_ads" table and to view the first 10 rows of the "users" table.

Uploaded by

Edu Free
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views5 pages

Mysql Queries

The document discusses creating and querying tables in MySQL. It provides the SQL commands to create three tables: "users", "ads", and "served_ads". It also includes commands to load data from a CSV file into the "served_ads" table and to view the first 10 rows of the "users" table.

Uploaded by

Edu Free
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MySQL queries

I have created a database using in following tables.


Creating databases by using this command.
create database if not exists online ;

show databases;

In this document, you have to write the create table and the load table queries used to create the
following tables:

1. “users" table

create table [Link](id varchar(150),


age int, gender varchar(150),
internet_usage varchar(150) ,
income_bucket varchar(150),
user_agent_string varchar(150),
device_type varchar(150),
websites varchar(150),
movies varchar(150),
music varchar(150),
program varchar(150),
books varchar(150),
negatives varchar(150),
positives varchar(150));
2. “ads” table
create table [Link](text varchar(150),

category varchar(150),

keyword varchar(150),

campaign_id varchar(150) ,

status_Derived varchar(150),

target_gender varchar(150),

target_age_start int,

target_age_end int,

target_city varchar(150),

target_state varchar(150),

target_country varchar(150),

target_income_bucket varchar(150),

target_device varchar(150),

cpc double,

cpa double,
cpm_Derived double,

budget double,

current_slot_budget_Derived double,

date_range_start varchar(150),

date_range_end varchar(150),

time_range_start varchar(150),

time_range_end varchar(150));

3. “served_ads” table
create table online.served_ads(

request_id varchar(150),

campaign_id varchar(150),

user_id varchar(150),

auction_cpm double,
auction_cpc double,

auction_cpa double,

target_age_range varchar(150),

target_location varchar(150),

target_gender varchar(150),

target_income_bucket varchar(150),

target_device_type varchar(150),

campaign_start_ime varchar(150),

campaign_end_time varchar(150),

timestamp varchar(150));

load file of “~/users_500k.csv'”


LOAD data local infile '~/users_500k.csv' INTO TABLE served_ads fields terminated BY ',' ignore 1
rows;
This command is used to show tables which are created.
Show tables ;

This command is used to get 10 rows from users tables.


Select * from users limit 10;

You might also like