When can you rename a table?

There will be times when you must rename a table. Before you do, please be aware that any objects that are dependent on the table will need to be updated as well. Access does not rename references for you as other technologies do.

This feature works the same in all modern versions of Microsoft Access: 2010, 2013, and 2016.

  1. Right-click on the table that you wish to rename.
  2. Choose Rename.
    When can you rename a table?
  3. Type the new name and hit the Enter key to confirm the name.
  4. Note that you will have a chance to CTRL+Z to undo right away.

RENAME TABLE allows you to rename an existing table in any schema (except the schema SYS).

To rename a table, you must either be the database owner or the table owner.

Syntax

RENAME TABLE table-Name TO new-Table-Name

If there is a view or foreign key that references the table, attempts to rename it will generate an error. In addition, if there are any check constraints or triggers on the table, attempts to rename it will also generate an error.

Statement dependency system

The RENAME TABLE statement is not allowed if there are any open cursors that reference the table that is being altered.

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    Sometimes we may want to rename our table to give it a more relevant name. For this purpose we can use ALTER TABLE to rename the name of table.

    *Syntax may vary in different databases. 
     
    Syntax(Oracle,MySQL,MariaDB):
     

    ALTER TABLE table_name RENAME TO new_table_name;

    Columns can be also be given new name with the use of ALTER TABLE.

    Syntax(MySQL, Oracle):

    ALTER TABLE table_name RENAME COLUMN old_name TO new_name;

    Syntax(MariaDB):

    ALTER TABLE table_name CHANGE COLUMN old_name TO new_name;

    Sample Table:
    Student

    ROLL_NONAMEAGE
    1 Ram 20
    2 Abhi 21
    3 Rahul 22
    4 Tanu 19

    QUERY:

    • Change the name of column NAME to FIRST_NAME in table Student.
    ALTER TABLE Student RENAME COLUMN NAME TO FIRST_NAME;

    OUTPUT:
     

    ROLL_NOFIRST_NAMEAGE
    1 Ram 20
    2 Abhi 21
    3 Rahul 22
    4 Tanu 19
    • Change the name of the table Student to Student_Details
    ALTER TABLE Student RENAME TO Student_Details;

    OUTPUT:
    Student_Details
     

    ROLL_NOFIRST_NAMEAGE
    1 Ram 20
    2 Abhi 21
    3 Rahul 22
    4 Tanu 19

    This article is contributed by Shubham Chaudhary. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks. 

    Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
     

    next → ← prev

    In some situations, database administrators and users want to change the name of the table in the SQL database because they want to give a more relevant name to the table.

    Any database user can easily change the name by using the RENAME TABLE and ALTER TABLE statement in Structured Query Language.

    The RENAME TABLE and ALTER TABLE syntax help in changing the name of the table.

    Syntax of RENAME statement in SQL

    Examples of RENAME statement in SQL

    Here, we have taken the following two different SQL examples, which will help you how to change the name of the SQL table in the database using RENAME statement:

    Example 1: Let's take an example of a table named Cars:

    Car NameCar ColorCar Cost
    Hyundai Creta White 10,85,000
    Hyundai Venue White 9,50,000
    Hyundai i20 Red 9,00,000
    Kia Sonet White 10,00,000
    Kia Seltos Black 8,00,000
    Swift Dezire Red 7,95,000

    Table: Cars

    • Suppose, you want to change the above table name into "Car_2021_Details". For this, you have to type the following RENAME statement in SQL:
    • After this statement, the table "Cars" will be changed into table name "Car_2021_Details".

    Example 2: Let's take an example of a table named Employee:

    Emp_IdEmp_NameEmp_SalaryEmp_City
    201 Abhay 25000 Goa
    202 Ankit 45000 Delhi
    203 Bheem 30000 Goa
    204 Ram 29000 Goa
    205 Sumit 40000 Delhi

    Table: Employee

    • Suppose, you want to change the name of the above table into the "Coding_Employees". For this, you have to type the following RENAME statement in SQL:
    • After this statement, the table "Employee" will be changed into the table name "Coding_Employees".

    Syntax of ALTER TABLE statement in SQL

    In the Syntax, we have to specify the RENAME TO keyword after the old name of the table.

    Examples of ALTER TABLE statement in SQL

    Here, we have taken the following three different SQL examples, which will help you how to change the name of the table in the SQL database using ALTER TABLE statement:

    Example 1: Let's take an example of a table named Bikes:

    Bike_NameBike_ColorBike_Cost
    KTM DUKE Black 185,000
    Royal Enfield Black NULL
    Pulsar Red 90,0000
    Apache White NULL
    Livo Black 80,000
    KTM RC Red 195,000

    Table : Bikes

    • Suppose, you want to change the name of the above table into "Bikes_Details" using ALTER TABLE statement. For this, you have to type the following query in SQL:

    After this statement, the table "Bikes" will be changed into the table name "Bikes_Details".

    Example 2: Let's take an example of a table named Student:

    Stu_IDStu_NameStu_Marks
    1001 Abhay 85
    1002 Ankit 75
    1003 Bheem 60
    1004 Ram 79
    1005 Sumit 80

    Table : Student

    • Suppose, you want to change the name of the above table into "MCA_Student_Details" using ALTER TABLE statement. For this, you have to type the following query in SQL:

    After this statement, the table "Student" will be changed into table name "MCA_Student_Details".

    Example 3: Let's take an example of a table named Employee:

    Emp_IdEmp_NameEmp_SalaryEmp_City
    201 Abhay 25000 Goa
    202 Ankit 45000 Delhi
    203 Bheem 30000 Goa
    204 Ram 29000 Goa
    205 Sumit 40000 Delhi

    Table: Employee

    • Suppose, you want to change the name of the above table into the "Coding_Employees" using an ALTER TABLE statement. For this, you have to type the following query in SQL:

    After this statement, the table "Employee" will be changed into the table name "Coding_Employees".


    Next TopicSQL TRUNCATE TABLE

    ← prev next →

    When can you rename a table in access?

    Note: You must close all open objects that reference the table before you can rename it. Type the new name and then press ENTER.

    Can you rename a table?

    To rename a table: Click on the table. Go to Table Tools > Design > Properties > Table Name.

    How can we rename a table in SQL?

    The first one uses the ALTER TABLE syntax:.
    ALTER TABLE old_table_name RENAME new_table_name; The second way is to use RENAME TABLE :.
    RENAME TABLE old_table_name TO new_table_name; RENAME TABLE offers more flexibility. ... .
    RENAME TABLE products TO products_old, products_new TO products;.

    Can we rename a table in SQL Server?

    Using SQL Server Management Studio In Object Explorer, right-click the table you want to rename and choose Design from the shortcut menu. From the View menu, choose Properties. In the field for the Name value in the Properties window, type a new name for the table.