SQL Tutorial How to rename tables or columns
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=KDoaM76UA0g
Another fantastic SQL Tutorial brought to you by BeardedDev. • In this video tutorial we learn how to rename columns and tables in SQL: • SQL Tutorial - How to rename tables o... • If you want to check out my video tutorial on how to create tables, click on the link: SQL Tutorial - Create Table with Constraints - • SQL Tutorial - Create Table with Cons... • We are all human and that means sometimes we make mistakes when naming objects such as tables and columns in our database. • To rename columns or tables we can use the system stored procedure sp_rename. • In this video we go through examples using sp_rename to rename tables, rename columns and there is even a bonus query on how to rename an index. • If you are new to the channel and are interested in learning Data Development and Business Intelligence, hit the subscribe button or check out all of my videos using this link: / @beardeddevdata • SQL Syntax: • CREATE TABLE dbo.CstomerDetals • ( • Cust_Id INT IDENTITY(1, 1) NOT NULL • CONSTRAINT PK_Customr_Cust_Id PRIMARY KEY (Cust_Id) • , Title CHAR(5) NULL • , First_Name VARCHAR(50) NOT NULL • , Middle_Name VARCHAR(50) NOT NULL • , Last_Name VARCHAR(50) NOT NULL • , DBO DATE NOT NULL • ) • EXEC sp_rename 'dbo.CstomerDetals', 'CustomerDetails' • EXEC sp_rename 'dbo.CustomerDetails.DBO', 'DOB', 'COLUMN' • EXEC sp_rename 'dbo.CustomerDetails.PK_Customr_Cust_Id', 'PK_Customer_Cust_Id', 'INDEX' • Before renaming any objects it is important to identify any objects such as stored procedures that reference the object you are renaming as these will show an error that the name is not recognised when run.
#############################
