How to set default to "not null" when creating fields in phpmyadmin

I'm using phpmyadmin to create the fields for an empty tablet.  For most of my fields I want to allow null values.  However, phpmyadmin always defaults to not null on the field creation screen.  Is there a fairly easy way to change this default?

I am currently using phpMyAdmin 2.6.3-pl1 and MySQL 4.1.13.

Since phpmyadmin is written in PHP, I suspect one could look through the code and fix this.  However, since this seem like something others might have wanted to do, I'm thinking maybe there is a configuration setting for phpmyadmin or someone has already figured out how to easily customize phpmyadmin's code to do this.
LVL 1
davidvieiraAsked:
Who is Participating?
 
kblack05Connect With a Mentor Commented:
In phpmyadmin directory is a file called tbl_create.php which contains some lib references, and also some create references. Chances are what you are attempting to do will require recoding this file, particularly the areas where these types of statements occur:

// Builds the 'create table' statement
    $sql_query      = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $sql_query . ')';
    $query_cpy      = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $query_cpy . "\n" . ')';

    // Adds table type, character set and comments
    if (!empty($tbl_type) && ($tbl_type != 'Default')) {
        $sql_query .= ' ' . PMA_ENGINE_KEYWORD  . ' = ' . $tbl_type;
        $query_cpy .= "\n" . PMA_ENGINE_KEYWORD . ' = ' . $tbl_type;
    }
    if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
        $sql_query .= PMA_generateCharsetQueryPart($tbl_collation);
        $query_cpy .= "\n" . PMA_generateCharsetQueryPart($tbl_collation);
    }

    if (!empty($comment)) {
        $sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
        $query_cpy .= "\n" . 'COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
    }

    // Executes the query
    $error_create = false;
    $result    = PMA_DBI_try_query($sql_query) or $error_create = true;

    if ($error_create == false) {
        $sql_query = $query_cpy . ';';
        unset($query_cpy);
        $message   = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;

While I thought there was a config time option for this, it seems the public at large uses the default types in the creation, then uses the structure tool (tab) to modify any types.

0
 
kblack05Commented:
If you take a look at the documentation, there are settings in the PhPMyAdmin config to handle how it creates tables...

http://wiki.cihar.com/pma/Category:Configuration

The latest stable version is phpMyAdmin 2.9.1 so you might consider upgrading the software. I think that this issue might have been changed.
0
 
davidvieiraAuthor Commented:
Shortly after making my original post I did up date phpMyAdmin to 2.9.1 and that did not address the issue.

I looked at the documentation you mention specifically concentrating on the Configuration Directives page at http://wiki.cihar.com/pma/Config and did not find the solution to my question.  However, that document was particularly user friendly so it is possible that I missed something buried there.

kblack05,

I also did not find any information that seemed directly related to how phpMyAdmin creates tables.  Could you refer me to a more specific place in the documentation?

Thanks.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
davidvieiraAuthor Commented:
kblack05,

This is a little more complicated than I wanted to go at the moment, but thanks for the information.  I've accepted your answer and added it to my knowledge base for when I'm ready to try that.  

Maybe phpMyAdmin will add that as a config option before then.  :)

Thanks.
0
 
kblack05Commented:
Sorry I wish there was a cleaner way. Perhaps there is another frontend you might consider. I think that there are some competitors to PhPMyAdmin which may work.

Looks like phpMyFlashAdmin has some interesting features, right on the front page it talks about default data structure options, though I have not used it.

http://www.bigwebmaster.com/2230.html
0
 
davidvieiraAuthor Commented:
Thanks kblack05.  

I only read through the features list on the home page for phpMyFlashAdmin, but it looks like it might have the potential to replace Access in a database unit of a high-school class we teach here.  There is some interest in using mySQL instead of Access but for novices the graphical query and relationship tools in access are hard to beat.  If we could switch over to mySQL without loosing the simplicity we need for most students, it would be great for more advanced students who might be interested in doing something in PHP, which think is simpler than having to use VB or VBscript with an Access database. (I've done both some ADO programming in VB with access and PHP programming with mySQL.)
0
 
kblack05Commented:
I believe that switching to mysql would be much more beneficial. It will be around long after MSAccess is no longer supported, and is constantly being updated. Agreed that the tools for Access are much more stylistic, and intutive for children to learn, which at the end of the day makes all the difference.

At one point there was a tool called "MySQLFront" http://www.mysqlfront.de/ but unfortunately someone decided the public did not have as much interest in ease of use as their pocketbook. :( This is a great example of what NOT to do in the open source world ). A replacement has come along which I know nothing about but may potentially investigate, which is called HeidiSQL http://www.heidisql.com/

Honestly I wish I had more answers and resources for you, sometimes the growth of Open Souce deals with pains caused by lack of attentiveness and greed. Overall it is my choice, and always will be, to advocate MySQL and other open source platforms such as Linux and FreeBSD. These software packages were built around performance, and gradually gravitate towards ease of use.

MS products are built with monetary return and ease of use in mind, and gradually gravitate towards availability based on affordability.

Perhaps in the not too distant future, the reality of the two will end up somewhere in between, though I always hope that it will be a free and unified open source world.
0
 
kblack05Commented:
What do you know? HeidiSQL looks a lot like the MSAccess interface! In fact I think it has everything that MySQLFront had, and then some. Worth looking at.
0
 
davidvieiraAuthor Commented:
Thanks!  I passed on the information to the teachers of the courses where Access is currently used.  The last three comments piggybacking on my original message is worth of a thread all it's own.  If I could grant you Expert's points for these recommendations too, I would.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.