

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I add a check constraint to a table in MySQL?
To add a check constraint to a table, let us first create a table.
CREATE table yourTableName ( Column_name1 datatyep, . . . . Column_name N datatype, check( condition) );
The following is how you can check the age by creating a check constraint.
check(Age>=45)
Let us now create a table and while creating a table, we will add the above shown check constraint for age.
mysql>CREATE table addCheckConstraintDemo -> ( -> Age int, -> check(Age>=45) -> ); Query OK, 0 rows affected (0.55 sec)
- Related Questions & Answers
- How do I remove a uniqueness constraint from a MySQL table?
- How do I alter a MySQL table column defaults?
- How do I detect if a table exist in MySQL?
- How can we check the indexes created by a UNIQUE constraint on a MySQL table?
- How can we add a FOREIGN KEY constraint to the field of an existing MySQL table?
- How do I add to each row in MySQL?
- How do I list all the columns in a MySQL table?
- How do I show unique constraints of a table in MySQL?
- How do I clone the structure of a table in MySQL?
- How do I show the schema of a table in a MySQL database?
- How can we drop UNIQUE constraint from a MySQL table?
- How to add a column in a table in MySQL?
- How do I get the creation date of a MySQL table?
- How add a unique key constraint to a column of a table in a database using JDBC API?
- Add a positive integer constraint to an integer column in MySQL?
Advertisements