![sql rename table sql rename table](https://i.stack.imgur.com/b5Zwc.png)
The syntax for using the TRUNCATE statement is as below: When the need arises to delete the data inside the table, and the table structure such as columns etc., need to remain as it is, we can use the TRUNCATE statement, which only deletes the data from the table but not the table.
#SQL RENAME TABLE HOW TO#
If we want to alter the table name ‘STUDENTS’, it can be done as below.ĪLTER TABLE STUDENTS RENAME TO STUDENT_NEW How to Truncate Table? ALTER TABLE statement is used to rename the table.ĪLTER TABLE table_name RENAME TO table_name_new
![sql rename table sql rename table](https://www.tutorialgateway.org/wp-content/uploads/SQL-Rename-Column-6.png)
![sql rename table sql rename table](https://www.sqlservertutorial.org/wp-content/uploads/2020/09/SQL-Server-rename-table-example-3.png)
It so happens that sometime after we have created the table, we want to rename it. The above query will provide the below result: ROLL The syntax for the same is as below:ĭELETE FROM table_name WHERE ĭELETE FROM STUDENTS WHERE SUBJECT= ‘MATH’ Whenever the requirement arises, and we do not want certain records, the delete statement is used along with the Where clause to remove those records. The delete statement is used in SQL to delete the records that exist in the table currently. When we use the DELETE statement without the WHERE clause, all the rows of a table shall be deleted, but the table structure will remain the same. So we need to be careful before executing a drop statement as all the information related to the table will be removed from the database. the data and table definition for the table will be removed. The above query will drop the table ‘STUDENTS,’ i.e. INSERT INTO STUDENTS VALUES (9,'Rahul',10,'SCIENCE') Īfter inserting the data, we can see the data inserted to the table as below: INSERT INTO STUDENTS VALUES (11,'Priya',11,'MATH') INSERT INTO STUDENTS VALUES (8,'Ram',12,'ENG') We can insert values to the table ‘STUDENTS’ as below: Let us create the table ‘STUDENTS’ as below: Hadoop, Data Science, Statistics & others