I guess i'm confused about what NOT NULL means when defining a table column. i thought it meant it had to contain something, and would return an error if you did an insert without putting something into it.(?)
my create table query looks like this,
create table links_other (
id int not null auto_increment primary key,
manid int not null,
url varchar(50) not null,
link varchar(50) not null
)
but then my populate query is this. this populate query does not contain any data for the link column. yet it runs successfully,
By default MySQL will fill a VARCHAR which has not been specified with an empty string if the column is defined as NOT NULL. My question would be, why would you want a NOT NULL, could you not test for empty strings?
Your logic was correct but not for MySQL.
Microsoft SQL will do exactly what you think would of happen here.
You could also define default value which will be inserted by system automatically if your query does not provide value for it....
Your statement for table create in MySQL will look like this:
create table links_other (
id int not null auto_increment primary key,
manid int not null,
url varchar(50) DEFAULT 'www.google.com',
link varchar(50) DEFAULT 'none'
)
and if really want to mess up your life you can define default like this:
default NULL -- once again this is for MySQL not for MS SQL database...
Bookmarks