Tagged Questions
0
votes
1answer
49 views
Creating a partial unique constraint for MySQL
I have the same question as asked in a previous post: PostgreSQL multi-column unique constraint and NULL values. But the solution there is not applicable as I am using MySQL instead of PostgreSQL.
My ...
0
votes
1answer
53 views
WITH ROLLUP WHERE NULL = x
I tried to find this question somewhere else on here, and found a couple that were similar to it -- but all the answers seemed pretty convoluted, and I think it was surprising to me because I just ...
3
votes
1answer
126 views
A function to check if a column allows NULL
Is there a way to write an insert/update query that checks if a column allows NULLs: If it does set the column to NULL, and '' (empty string) otherwise?
I would be something like:
UPDATE mytable
...
3
votes
2answers
2k views
Select column names whose entries are not null
I would like to have a list of those columns of a table that have at least one not-NULL data entries in them.
In other words, I would like to get the column names for which the following returns at ...
2
votes
3answers
182 views
Empty LONGTEXT or NULL?
In my MySQL DB I have one field called html_contents that contains all the html to be shown in a webpage. Obviously the html could be huge, and certaintly bigger than 64KB, therefore I decided to use ...
1
vote
1answer
342 views
How to change the display of an empty string in mysql command line tool?
I'm maintaining a database with InnoDB tables.
These tables have some columns of type (from show create table):
`val0` varchar(30) default NULL,
`val1` varchar(30) default NULL,
etc...
From the ...
1
vote
2answers
128 views
MYSQL only Show columns which allow null
I need to be able to pull the column names which allow a NULL value, I know that
show columns from TABLE
Will give show me the table properties and whether or not the column allows null values, ...
2
votes
1answer
414 views
Are many NULL columns harmful in mysql InnoDB?
As I explored the clustered B-tree index system of InnoDB, I think that the presence of many NULL (or small) columns has no significant effect on InnoDB performance.
Does the presence of excess ...
4
votes
1answer
3k views
MySQL column defined with NOT NULL is allowing nulls
I had created a table a while back and started adding data to it. Recently I added a new column (address) to it with NOT NULL as part of the new column. The old rows (pre-addition) are still null, ...
2
votes
1answer
1k views
MySQL - LOAD DATA INFILE - Handling unescaped NULL in INFILE or creating INFILE with escaped NULL
I am selecting data from a database on server A, dumping the output into a file locally, and then doing a LOAD DATA INFILE on my local database. The bash command looks something like this:
mysql -e ...
26
votes
2answers
4k views
NULL or NOT NULL by default?
In MySQL, is it better to always allow nulls unless you know a field is required, or always use Not Null unless you know a field will contain nulls? Or doesn't it matter?
I know in some DBMSs they ...