Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Inimigor

Help with college programming task

If the email field is mandatory use this query containing the "NOT NULL" keyword.

#Select the database containing the table you want to editUSE <database_name>;#Alter the table to add a column named 'email' which can be up to 30 characters long and IS required to be filled inALTER TABLE <table_name> ADD email varchar(30) NOT NULL;

Else use this query which means the user isn't required to enter an email.

#Select the database containing the table you want to editUSE <database_name>;#Alter the table to add a column named 'email' which can be up to 30 characters long and is NOT required to be filled inALTER TABLE <table_name> ADD email varchar(30);

Recommended Posts

Posted · Original PosterOP

Hello everyone, i have a project that i haven't touched in almost 2 years that the teacher is now back at college and assigned a task, add a line to it, there's just a problem, the MySQL workbench version has updated, and i don't remember how to add new collums to the table, and i used mostly apache before, i'm kind of lost in mysql 6

I have to add a line for email on the sign up screen of the project. and replicate it to the mysql server. quite simple, but i'm not used to programming, and haven't done any in a looong time...


|CPU : Core i7 4770 (non-K :( ) | GPU : XFX RX 480 GTR 8GB @ 1385Mhz | MoBo: Gigabyte GA-Z87-HD3 | PSU: XFX 850W PRO | Case: In-Progress Silverstone TJ-07 |

Zenfone 2 ZE551ml 32GB + 64GB SD - Rooted LineageOS |

 

Link to post
Share on other sites
Posted · Best Answer

If the email field is mandatory use this query containing the "NOT NULL" keyword.

#Select the database containing the table you want to editUSE <database_name>;#Alter the table to add a column named 'email' which can be up to 30 characters long and IS required to be filled inALTER TABLE <table_name> ADD email varchar(30) NOT NULL;

Else use this query which means the user isn't required to enter an email.

#Select the database containing the table you want to editUSE <database_name>;#Alter the table to add a column named 'email' which can be up to 30 characters long and is NOT required to be filled inALTER TABLE <table_name> ADD email varchar(30);

--

Link to post
Share on other sites
Posted · Original PosterOP

This one did the trick! Thanks man! (Awesome username by the way!)

 

#Select the database containing the table you want to editUSE <database_name>;#Alter the table to add a column named 'email' which can be up to 30 characters long and IS required to be filled inALTER TABLE <table_name> ADD email varchar(30) NOT NULL;

|CPU : Core i7 4770 (non-K :( ) | GPU : XFX RX 480 GTR 8GB @ 1385Mhz | MoBo: Gigabyte GA-Z87-HD3 | PSU: XFX 850W PRO | Case: In-Progress Silverstone TJ-07 |

Zenfone 2 ZE551ml 32GB + 64GB SD - Rooted LineageOS |

 

Link to post
Share on other sites

Come on, this kind of question is just asking for http://lmgtfy.com. It takes more time to write a question and wait for answer than just do simple search yourself. If you can't get answer on your own for this simple question than I have to ask why are you studying there.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Newegg

×