SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Services
  • Product
    🏋️ GyManage 📱 More to come
Contact
  1. SQL
  2. SQL Commands

Text copied!

« Previous
Next »

SQL Commands

Dec. 16, 2022, 8:09 p.m. under SQL

  • Hi! You should check Database online post first.

    Understanding SQL command is essential for working with databases. SQL command allows user to retrieve, manipulate, and manage data stored in the databases. It include commands like SELECT, INSERT, UPDATE, DELETE, CREATE and DROP etc.

    SQL statement :

    SQL command is also referred to as "SQL statement".

    SQL query :

    A set of SQL command/statement used to retrieve data from a database is known as a "SQL query".

    SQL commands can be broadly categorized into three types :

    1. Data Definition Language (DDL)

    2. Data Manipulation Language (DML)

    3. Data Query Language (DQL)

    SQL Commands
    These are some essential commands which form the core of SQL programming :
    1. CREATE :

    "CREATE" command is used to create a new database object such as a tables, functions, views and stored procedure. Here's is an example of creating [SQL Tutorial] table -

    CREATE TABLE [SQL Tutorial] (
        Sno INT PRIMARY KEY,
        FirstName VARCHAR(50) NOT NULL,
        LastName VARCHAR(50),
        Age INT CHECK (age > 18),
        Gender VARCHAR(10) CHECK (gender IN ('Male', 'Female')),
        Salary DECIMAL(18,2)
    );
            
    2. DROP :

    "DROP" command is used to delete a database object. Here's is an example of removing [SQL Tutorial] table -

    DROP TABLE [SQL Tutorial];
            
    3. ALTER :

    "ALTER" command is used to modify the structure of an existing database object. Here's is an example of modifying the structure of the existing [SQL Tutorial] table -

    ALTER TABLE [SQL Tutorial]
    ADD Address VARCHAR(100);
            
    4. TRUNCATE :

    "TRUNCATE" command is used to remove all data from a table, while keeping the table structure intact. Here's is an example of removing all data from [SQL Tutorial] table -

    TRUNCATE TABLE [SQL Tutorial];
            
    5. INSERT :

    "INSERT" command is used to add new data to a table. Here's is an example of adding new records in [SQL Tutorial] table -

    INSERT INTO [SQL Tutorial]  ( FirstName, Age )
    VALUES ('Mike', 25),
                    ('Tim', 35),
                    ('Jim', 40);
            
    6. UPDATE :

    "UPDATE" command is used to modify existing data in a table. Here's is an example modifying existing data in [SQL Tutorial] table -

    UPDATE  [SQL Tutorial] 
    SET Gender = 'Male';
            
    7. DELETE :

    "DELETE" command is used to remove data from a table. Here's is an example removing data from [SQL Tutorial] table -

    DELETE FROM [SQL Tutorial] 
    WHERE Age = 25;
            
    8. SELECT :

    "SELECT" command is used to retrieve data from one or more tables in a database. This command is the most commonly used command and is considered as the backbone of SQL. It is essential to understand this command in order to effectively work with relational databases. Here's is an example retrieving data from [SQL Tutorial] table -

    SELECT * FROM [SQL Tutorial];
            

    Frequently Asked Questions :

    What are the 5 basic SQL commands?

    The 5 basic SQL commands are: SELECT, INSERT, UPDATE, DELETE, and CREATE.

    What is the SQL command?

    An SQL command is a statement used to perform operations on a database, such as querying data or modifying its structure.

    What is DDL and DML and DCL in SQL?

    DDL (Data Definition Language) is for defining the structure of the database, DML (Data Manipulation Language) is for managing data within the database, and DCL (Data Control Language) is for controlling access and permissions in the database.

    What is SQL and its types?

    SQL (Structured Query Language) is a domain-specific language used for managing relational databases, with types including MySQL, PostgreSQL, SQL Server, Oracle, etc.
    Thank You! You should check SQL tables post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    CONCAT function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    GETDATE function

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    CHOOSE function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India

    © 2024 Copyright | All Rights Reserved | Legal