I have “Customer” table:
CREATE TABLE Customer
(
ID INTEGER NOT NULL DEFAULT 0,
Username CHAR(50) NOT NULL,
Password CHAR(100) NOT NULL,
LastName CHAR(20) NOT NULL,
PhoneNumber BIGINT NOT NULL,
MobileNumber BIGINT NOT NULL,
PRIMARY KEY (ID)
)
;
I used char for password type, is this right? And for mobile number I used bigint, is this right? If not what should I do ? And what is the SQL statement for it? Thanks.
As these fields will all be variable lengths you should definitely use VARCHAR instead of CHAR for ‘Username’, ‘Password’ & ‘Lastname’. If you have limits on the lengths these then you can always limit the VARCHAR type to that limit.
As for ‘PhoneNumber’ & ‘MobileNumber’, you won’t be performing any calculations with these values, so there’s no reason not to store them as VARCHAR, not to mention that telephone number often contain a 0 as the first character which cannot be stored as an INT of any kind.
Something like: