Jump to content
  • change the '0' values to NULL in the database


    MrFreak
    • Status: devacknowledged
      Main Category: Core / Mangos Daemon
      Sub-Category: Unknown
      Version: 0.20 Milestone: 20 Priority: Normal
      Implemented Version: 0.20

    change the '0' values to NULL in the database

    Look at the uptime table in the realmd db: [url]http://getmangos.eu/wiki/Reference%20Information/DB/realm/uptime.md[/url]

    The default values are '0' and NULL. We should use NULL because it's faster and it doesn't take space - it just exists virtually. If we use '0' it's a char that needs to be stored and it will take away space on the HDD.


    User Feedback

    Recommended Comments

    Wiki page is wrong. Look at the "Nullable" column. Every item is set to "NOT NULL", but they default to NULL. Another problem is that a primary key should NEVER be NULL. Base don these two facts, you would be required to put in a zero for a PK, but you should also remember that a PK should not change once set. Seems like that table is in need of a refit!

    Link to comment
    Share on other sites

    This is odd as I'm pulling the information directly from the db itself using mysql:

    SELECT t.*,c.*
    FROM INFORMATION_SCHEMA.Tables T
    JOIN INFORMATION_SCHEMA.Columns C ON T.TABLE_NAME = C.TABLE_NAME
    WHERE T.TABLE_NAME 'dtproperties' AND T.TABLE_SCHEMA 'INFORMATION_SCHEMA'
    AND t.Table_schema='newr0' AND c.Table_schema='newr0'
    ORDER BY T.TABLE_NAME, C.ORDINAL_POSITION

    replace the 2 "newr0" with your db name

    Link to comment
    Share on other sites

    [quote=Xenithar]Wiki page is wrong. Look at the "Nullable" column. Every item is set to "NOT NULL", but they default to NULL. Another problem is that a primary key should NEVER be NULL. Base don these two facts, you would be required to put in a zero for a PK, but you should also remember that a PK should not change once set. Seems like that table is in need of a refit![/quote]

    If you set NULL as the value for a primary key it will increment the value by 1 based on the previously highest number. You have to enable auto_increment for this.

    I also noticed that the primary keys are the IDs for the realm so they are multiple times occurring. Problem is that a primary key should be unique but we got a lot of rows with the primary key value 1 so that is invalid. There should be a column called uptimeID or something like that which is the primary key. The reference on selecting or deleting stuff would happen on that uptimeID then and not anymore on the realmid which isn't unique.

    I'm unsure why the column 'starttime' is a primary key. I don't see any use for that. It should be unique but not a primary key.

    Link to comment
    Share on other sites

    A quick and dirty fix would be to do this.
    [code]
    entry, int, PK, unique, auto inc, not null
    realmid, uint, not null
    starttime, big uint, not null
    uptime, big uint, not null
    max_players, small uint, not null
    [/code]
    Also, you do not have to specify the PK column when adding data. I never do, and they teach you not to in colleges now. For example, to add entries above, you would insert realmid, starttime, uptime, and max_players. The DB will auto-assign (and increment) the entry field. This is who it works on MSSQL, MySQL, and MariaDB. Not sure about PostgreSQL.

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use