January 18, 2021

SQL Tutorial – How to rename tables or columns



Another fantastic SQL Tutorial brought to you by BeardedDev.

In this video tutorial we learn how to rename columns and tables in SQL:

If you want to check out my video tutorial on how to create tables, click on the link: SQL Tutorial – Create Table with Constraints –

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:

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.

Nguồn: https://belahanajima.com/

Xem thêm bài viết khác: https://belahanajima.com/cong-nghe/

Related Posts

Benerin Komputer Reset Jumper Bios / Cmos #1

July 4, 2020

July 4, 2020 43

komputer ini gak bisa masuk ke windows hanya ada kedip kedip garis strip di kiri atas layar,saya coba benerin dengan...

Winrar password remover tool how to Remove zip/rar file password in hindi

July 1, 2020

July 1, 2020 20

Zip/winrar password remover. how to remove winrar file password. is video me apko rar file password kaise crack karte hai...

re:plus – Time Goes By feat. Hydroponikz & Anika

July 4, 2020

July 4, 2020 36

2010.03.03 In stores itunes Hip Hop chart No.1 re:plus 1st album “everlasting truth” official Music Video -Time Goes By feat....

How To Reset Mi Band 2 Hrx Edition | Mi band hrx pairing problem | Hindi

July 8, 2020

July 8, 2020 32

FLIPKART BUY == Mi Band – HRX Edition Mi band hrx pairing problem | Mi band Pair or unpair problem...

How to unlock VBA Protect without password. 100% working. Without any software

July 1, 2020

July 1, 2020 36

How to unlock VBA Protect without password. 100% working. Without any software Unlock VBA Protect coding. Unlock any VBA project...

iPhone X,Xs,11 – How to Hard Reset, Factory Reset (Forgot Password)

July 4, 2020

July 4, 2020 49

An Easy step by step guide which shows you how to Reset your iPhone or iPad. —————————————————————————- 📷My Youtube Gear🎥...

How to Repair a DEAD Computer

June 28, 2020

June 28, 2020 28

In this video, I have an HP computer that will not boot-up. Watch as I explain the diagnostic process and...

How to Reset Laptop Window 10 | Laptop Ko Reset Kaise Kare

July 5, 2020

July 5, 2020 50

How to Reset Laptop Window 10 | Laptop Ko Reset Kaise Kare Hi I am yogi Yogendra. Welcome to our...

How to Fix Automatic Repair Loop in Windows 10

July 6, 2020

July 6, 2020 29

In this tutorial you will learn different ways to fix Windows 10 startup issues like Windows 10 Automatic Repair Loop,...

How to Fix Automatic Repair Loop in Windows 10 – Startup Repair Couldn’t Repair Your PC

July 2, 2020

July 2, 2020 24

This video shows how you can fix startup error with automatic repair loop in Windows10. ✅ For updated instructions, you...

How To Erase and Reset a Mac back to factory default

July 5, 2020

July 5, 2020 31

I show you how to erase and reset a Mac back to factory settings in my step-by-step guide. Make sure...

Windows 7 Startup Repair , NOT STARTING , BOOTING PROBLEM

July 4, 2020

July 4, 2020

Free Subscribe & Get Download Link: Windows 7 Startup Repair How to Fix: Windows 10 startup repair: How to Format...

Cấu hình modem cáp quang Viettel F606 chỉ tiết

July 3, 2020

July 3, 2020 10

Các bước cài đặt modem Viettel F606 chi tiết từ khôi phục cài đặt gốc đến đổi tên và mật...

Hướng dẫn Reset Window 10 về mặc định như lúc mới cài windows | namloan ✅

July 5, 2020

July 5, 2020 34

✅ Bạn đã sử dụng Windows 10 được một thời gian và nhận thấy máy tính của bạn không hoạt...

iPhone 5s – How to Reset Back to Factory Settings​​​ | H2TechVideos​​​

July 4, 2020

July 4, 2020 39

4ukey can factory reset iPhone quickly and easily: 💡Tired of Your Phone? Trade it in for 💰$$$💰 Here: For More...

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *