ทบทวนโครงสร้างข้อผิดพลาด
เมื่อรันสคริปต์ต่อไปนี้:
INSERT INTO products (product_name, stock, price)
VALUES ('Trek Powerfly 5 - 2018', 10, 3499.99);
console ของ SQL Server จะแสดงผลดังนี้:
Msg 2627, Level 14, State 1, Line 1
Violation of UNIQUE KEY constraint 'unique_name'.
Cannot insert duplicate key in object 'dbo.products'.
The duplicate key value is (Trek Powerfly 5 - 2018).
ส่วนประกอบต่าง ๆ ของข้อผิดพลาดที่ได้รับ จากซ้ายไปขวา มีอะไรบ้าง?
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Transactions and Error Handling in SQL Server
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำจริง
เปลี่ยนทฤษฎีให้เป็นการลงมือทำด้วยแบบฝึกหัดเชิงโต้ตอบหนึ่งในของเรา
เริ่มแบบฝึกหัด