![]() Instead, the system will raise the notice saying no such table exists. This will prevent the system from throwing an error if none of the tables named tableName exists in the current database. To avoid such an error, we can use the IF EXISTS statement in our alter table syntax in the following way – ALTER TABLE IF EXISTS tableName This will result in the error after executing the above command output as follows –Įrror saying relation name SQL demo does not exist given as the output of executing the above command. ALTER TABLE SQL demo RENAME TO education Let us see what happens if we try to alter the table not in our database, say SQL demo. Hence, we can conclude that our table has been renamed successfully. After describing the educational_platforms, it contains the same structure and keys as that of our previously created educba table. This gives the following output – \d educba Īs can be seen that the educba table cannot be described as it has been renamed, and now none of the tables named educba exists in our database. Let us check using \d command after firing the above command to describe the educba and educational_platforms table. ![]() To rename the name of the table educba to educational_platforms, we can use the syntax mentioned above of alter table command in the following way – ALTER TABLE educba RENAME TO educational_platforms We can rename the name of the table using the alter table command. ![]() Check whether the table is created by \dt command that gives output – \dt ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |