0 votes
1 view
in SQL by (36k points)

Can anyone tell me how to create gender column in SQL?

1 Answer

0 votes
by (86.8k points)

Here is the syntax to create a gender column in SQL:

Create table table_name (

Gender Varchar (10) check (gender in ('Female','Male'))

Here we use CHECK constraint with GENDER column so that you cannot enter any entry other than Male or Female.

If you want to add a gender column to an already existing table:

ALTER TABLE TableName

                ADD CONSTRAINT myCheckConstraint CHECK (gender in ('Female','Male'))

If you want to learn SQL and writing SQL queries, I suggest this SQL Course by Intellipaat that provides Instructor-led training, certification, and also job assistance.

Related questions

0 votes
1 answer
0 votes
1 answer
asked May 8 in SQL by Sudhir_1997 (36k points)
0 votes
1 answer
asked Apr 22 in SQL by Sudhir_1997 (36k points)
0 votes
1 answer
asked Apr 20 in SQL by Sudhir_1997 (36k points)
0 votes
1 answer
asked Apr 19 in SQL by Sudhir_1997 (36k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...