SQL query to create a table with 100 car brands, prices, and features.
SQL table for car inventory with randomly generated data. Below is the SQL query to create the table and insert 100 records:
SQL
CREATE TABLE CarInventory (
CarID INT PRIMARY KEY,
Brand VARCHAR(50),
Price DECIMAL(10, 2),
Features VARCHAR(255)
);
INSERT INTO CarInventory (CarID, Brand, Price, Features)
VALUES
(1, 'Mercedes', 45742.11, 'Bluetooth, Heated Seats'),
(2, 'Chevrolet', 63911.72, 'GPS, Backup Camera, Sunroof, Heated Seats'),
-- ... (98 more records) ...
(100, 'Toyota', 34698.65, 'Keyless Entry');
SQL
CREATE TABLE CarInventory (
CarID INT PRIMARY KEY,
Brand VARCHAR(50),
Price DECIMAL(10, 2),
Features VARCHAR(255)
);
INSERT INTO CarInventory (CarID, Brand, Price, Features)
VALUES
(1, 'Kia', 77149.54, 'Launch Control, Brembo Brakes'),
(2, 'Ferrari', 21979.61, 'Adjustable Exhaust, Sport Suspension, High-Performance Tires'),
(3, 'Mercedes-Benz', 12837.12, 'High-Performance Tires, Adjustable Exhaust, Track Mode'),
-- ... (97 more records) ...
(100, 'Subaru', 66778.18, 'Launch Control, Sport Suspension, Brembo Brakes');
SQL
-- Create or replace the database
CREATE OR REPLACE DATABASE CarInventoryDB;
-- Create the CarInventory table
CREATE TABLE CarInventory (
CarID INT PRIMARY KEY,
Brand VARCHAR(50),
Price DECIMAL(10, 2),
Features VARCHAR(255)
);
-- Insert 100 car records (random data)
INSERT INTO CarInventory (CarID, Brand, Price, Features)
VALUES
(1, 'Kia', 77149.54, 'Launch Control, Brembo Brakes'),
(2, 'Ferrari', 21979.61, 'Adjustable Exhaust, Sport Suspension, High-Performance Tires'),
-- ... (97 more records) ...
(100, 'Subaru', 66778.18, 'Launch Control, Sport Suspension, Brembo Brakes');
-- Retrieve all records from the CarInventory table
SELECT * FROM CarInventory;
You can find CSV files with car models and features from the following sources:
- GitHub Repository:
- This repository provides a comprehensive dataset on US car models, covering entries from 1992 to 2023. It includes over 15,000 car records, making it a valuable resource for incorporating car data into applications1.
- This repository provides a comprehensive dataset on US car models, covering entries from 1992 to 2023. It includes over 15,000 car records, making it a valuable resource for incorporating car data into applications1.
- Gigasheet:
- The CarsData.csv table contains information on 97,712 cars, including details on model, year, price, transmission, mileage, fuel type, tax, mpg, engine size, and manufacturer. You can analyze trends in car prices, fuel efficiency, and tax rates across different models and manufacturers using this data2.
- The CarsData.csv table contains information on 97,712 cars, including details on model, year, price, transmission, mileage, fuel type, tax, mpg, engine size, and manufacturer. You can analyze trends in car prices, fuel efficiency, and tax rates across different models and manufacturers using this data2.
- Car API:

Leave a comment