Oscail naisc i dtáb nua
  1. Creating a database and retrieving information with SQL involves defining the database structure, inserting data, and running queries to extract meaningful results.

    1. Create a Database Use the CREATE DATABASE statement to define a new database:

    CREATE DATABASE IF NOT EXISTS MyDatabase;
    Cóipeáilte!

    Switch to the new database:

    USE MyDatabase;
    Cóipeáilte!

    This ensures all subsequent operations occur within the selected database .

    2. Create a Table Define tables with columns, data types, and constraints:

    CREATE TABLE Products (
    ProductID INT PRIMARY KEY,
    ProductName VARCHAR(50) NOT NULL,
    Price DECIMAL(10,2),
    Description TEXT
    );
    Cóipeáilte!

    This structure enforces unique IDs and ensures product names are mandatory .

    3. Insert Data Populate the table with sample records:

    INSERT INTO Products (ProductID, ProductName, Price, Description)
    VALUES (1, 'Laptop', 1200.00, '15-inch display'),
    (2, 'Mouse', 25.50, 'Wireless optical mouse');
    Cóipeáilte!

    4. Retrieve Information Use SELECT queries to fetch data:

    • All columns:

    SELECT * FROM Products;
    Cóipeáilte!
    • Specific columns:

    SELECT ProductName, Price FROM Products;
    Cóipeáilte!
  1. 20 Basic SQL Query Examples for Beginners - LearnSQL.com

      1. Selecting All Columns From One Table. This query is useful when you want to …
      2. Selecting One Column From One Table. You can use this query when you only …
      3. Selecting Two Columns From One Table. This query is useful when selecting …
      4. Selecting Two (or More) Columns From One Table and Filtering Using …
      5. Selecting Two Columns and Filtering Using an Equality Condition in WHERE. …
  2. Step-by-Step Guide to Creating and Querying a SQL …

    9 Márta 2025 · This guide walks you through creating a database, connecting to it, creating tables, inserting data, and executing various queries to …

  3. SQL Tutorial - GeeksforGeeks

    5 Samh 2025 · Whether you want to create, delete, update or read data, SQL provides commands to perform these operations. Widely supported …

  4. SQL CREATE - W3Schools

    Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.

    Sampla úsáide
    CREATE DATABASE testDB;
  5. SQL Tutorial: Learn SQL from Scratch for Beginners

    This SQL Tutorial helps you master SQL quickly and effectively through many hands-on and practical examples with quizzes.