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