Define a non-null constraint

Source: Internet
Author: User

We need to fill in some forms when we register members of some websites, some of which are required, and will not be able to complete the registration if you do not fill in the blanks. We also want to design the data table when some fields are required, such as student information table in the school number, name, age field is required, and personal hobbies, home phone numbers, such as the field is optional, so we design the following table sql:

MYSQL, MSSQLServer, DB2:CREATETABLE T_student (FnumberVARCHAR (20)NotNULL, FNameVARCHAR (20)Notnull, Fage int NOT null, Ffavorite varchar (20), FPhoneNumber varchar (20)) Oracle:CREATE table t_student (Fnumber VARCHAR2 (20) NOT null, FName VARCHAR2 (20) not null, Fage number (10) not null, Ffavorite VARCHAR2 (20), Fphonenumber VARCHAR2 (20))         

As you can see, unlike normal field definitions, the definition of a non-empty field adds "not NULL" after the type definition, and is defined in the same way as a normal field.

Define a non-null constraint

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.