MySQL: CHECK constraint is easy

preview_player
Показать описание
#MySQL #SQL #tutorial

The CHECK constraint is used to limit what values can be placed in a column.

00:00:00 intro
00:00:43 CHECK constraint for a new table
00:01:45 CHECK constraint for an existing table
00:02:30 demonstration
00:03:19 drop a CHECK constraint
00:03:40 conclusion
Рекомендации по теме
Комментарии
Автор

– The CHECK constraint is used to limit what values can be placed in a column.

CREATE TABLE employees(
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50),
hourly_pay DECIMAL (5, 2),
hire_date DATE,
CONSTRAINT chk_hourly_pay CHECK (hourly_pay >= 10.00)
);

ALTER TABLE employees
ADD CONSTRAINT chk_hourly_pay CHECK (hourly_pay >= 10.00);

INSERT INTO employees
VALUES (6, "Sheldon", "Plankton", 5.00, "2023-01-07");

ALTER TABLE employees
DROP CHECK chk_hourly_pay;

BroCodez
Автор

You're literally carrying me through Uni right now. Thank you, Bro. Truly.

MinhVu-bzfe
Автор

We literally started sql today your timing is great thank you.

TheLastRaven
Автор

You are good man you make it easy for us

mdjahangirhossain
Автор

That fast forwarded typing sound so satisfying

Vivek_xkt
Автор

Thank you !
Notice :
when i want to delete constraint check
drop check "constraintName" => is not working for me
but when i do : drop constraint "constraintName"
maybe the first syntax is not correct

and thank you again :) (FROM MOROCCO)

mhreda
Автор

your tutorial is great could please make a tutorial for node js and dyango 💗

avaygc
Автор

Can you make also mongo db and Java Spring tutorials? Thanks man. Because of you i learned MySQL. I was struggling and now im able to write my own database in Java using JDBC.

enlightened
Автор

I got Error Code: 3821. Check constraint 'check_hourly_pay' is not found in the table, may be I mistyped the constraint. How to find out what I gave the constraint name for that column?

sifatniloy
Автор

ALTER ADD not working with constrain. Error code 3819 Check Constraint 'chk_hourly_pay' is violated

MalayalamTele
Автор

there should be another name for this channel that is 'bro god" really you are god for us bro.

fsrinivas
Автор

Drop check doesn't work in Microsoft sql can anyone help

ابوعمر-ذسج
Автор

First comment !!! U make my day Bro :D

haole