SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. Rename table

Text copied!

« Previous
Next »

Rename table

Dec. 20, 2022, 12:18 p.m. under SQL

  • Hi! You should check Delete table post first.

    Renaming SQL table refers to the process of changing the name of an existing table to a new name.

    This is useful when you want to assign a meaningful name to the table and to standardize the naming convention of tables within a database.

    To rename SQL table, you can use the graphical user interface (GUI) or Transact-SQL (T-SQL).
    Here's an example of how to rename table using T-SQL :

    "sp_rename" store procedure is used to rename existing table to a new name. Here's the syntax :

    sp_rename 'old_table_name' ,  'new_table_name' ;
            

    As you can see in below image, [Product] table is present under [SQL Tutorial] database. Let's rename it as [ProductMaster].

    Rename table

    1. Run below SQL command in SSMS and "Ignore the given warning message" :

    USE [SQL Tutorial];
    GO
    sp_rename 'Product' ,  'productMaster' ;
            
    Rename table

    2. Above command will rename [Product] table as [ProductName].

    Rename table

    That's it! You have successfully renamed [Product] table as [ProductMaster] using T-SQL.

    Here's a step-by-step guide on how to rename SQL table using GUI :

    1. Expand the database that contains the table you want to rename >> Right-click on the table you want to rename in "Tables folder" >> Select "Rename".

    Rename table

    2. It will let you edit in table name, type the new table name >> Click "Enter".

    Rename table

    3. A message will appear asking you to confirm if you really want change the table name >> Select "Yes".

    Rename table

    4. There you go, [Product] table is renamed as [ProductMaster].

    Rename table

    That's it! You have successfully renamed [Product] table as [ProductMaster] using GUI.

    Frequently Asked Questions :

    How do I rename a table in SQL?

    To rename a table in SQL, use the "ALTER TABLE" statement followed by the "RENAME TO" clause.

    Is rename a command in SQL?

    "RENAME" is not a standalone command in SQL, but it's used within specific statements like "ALTER TABLE" for renaming tables.

    What is rename function in SQL?

    The rename function in SQL is a capability within the "ALTER TABLE" statement that allows changing the name of a table.

    How do you change the name of a table?

    You change the name of a table in SQL by using the "ALTER TABLE" statement followed by "RENAME TO" and specifying the new table name.
    Thank You! You should check Select table 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 Commands

    SQL Tables

    Create table

    Truncate table

    Delete 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 support@sqlforgeeks.com

    © 2025 Copyright™ | All Rights Reserved | Privacy Policy