Professional Web Applications Themes

Can I create an alias for a database ? - MySQL

hi, i got a question, We have a site that needs to be frozen every year for a snapshot (older versions need to be available) we do that by 'linking' the www directory to the year directory can the same be done with mysql ? for example if we have the databases 0506 0607 0708 can we alias 0708 to 'current' ? so that "SELECT * from current.whatever" would be the same as "SELECT * FROM 0708.whatever" ? Thx in advance :-) -- Arjen http://www.hondenpage.com...

  1. #1

    Default Can I create an alias for a database ?

    hi, i got a question,

    We have a site that needs to be frozen every year for a snapshot (older
    versions need to be available)

    we do that by 'linking' the www directory to the year directory

    can the same be done with mysql ?
    for example if we have the databases
    0506
    0607
    0708

    can we alias 0708 to 'current' ?
    so that "SELECT * from current.whatever" would be the same as "SELECT *
    FROM 0708.whatever" ?

    Thx in advance :-)

    --
    Arjen
    http://www.hondenpage.com
    Floortje Guest

  2. #2

    Default Re: Can I create an alias for a database ?

    == Quote from Floortje (enel)'s article 

    I've never read that anywhere and am not sure if you can do this in MySQL.


    --
    POST BY: lark with PHP News Reader
    lark Guest

  3. #3

    Default Re: Can I create an alias for a database ?

    On 11 Jun, 19:36, lark <net> wrote: 
    >
    > I've never read that anywhere and am not sure if you can do this in MySQL.
    >
    > --
    > POST BY: lark with PHP News Reader[/ref]

    I've no idea either. Fancy that.

    strawberry Guest

  4. #4

    Default Re: Can I create an alias for a database ?

    strawberry wrote: 
    >> I've never read that anywhere and am not sure if you can do this in MySQL.
    >>
    >> --
    >> POST BY: lark with PHP News Reader[/ref]
    >
    > I've no idea either. Fancy that.[/ref]

    Couldn't find it myself either ... a well it's open source :-)

    --
    Arjen

    www.arjenkarel.nl

    Floortje Guest

  5. #5

    Default Re: Can I create an alias for a database ?


    "Floortje" <enel> schreef in bericht
    news:466d8026$0$19837$wanadoo.nl... 

    i think you can do it with the 'ln' command:
    # cd /var/lib
    # ln -s 0708 current

    after this
    mysql> use 0708; show tables
    and
    mysql> use current; show tables
    should look the same...




    Luuk Guest

  6. #6

    Default Re: Can I create an alias for a database ?

    > can we alias 0708 to 'current' ? 

    I think it depends on what you want with the database. If it is just
    selects that you want, you can create views. (You can create a view that
    takes its data from another database.) If you want inserts, updates and
    such things, you might take a look at the FEDERATED storage engine
    (http://dev.mysql.com/doc/refman/5.1/en/federated-storage-engine.html).
    Not really meant for operations on the same physical server, but I do
    not think anybody will stop you to connect to localhost. You need to
    have a fairly recent MySQL server though.

    Best regards,
    --
    Willem Bogaerts

    Application smith
    Kratz B.V.
    http://www.kratz.nl/
    Willem Guest

  7. #7

    Default Re: Can I create an alias for a database ?

    Luuk wrote: 
    Cool ... ive set up a testing server on a virtual machine and copied the
    enitre site. Ill start testing this solution !!

    Thx

    --
    Arjen
    www.hondenpage.com
    Floortje Guest

  8. #8

    Default Re: Can I create an alias for a database ?

    Willem Bogaerts wrote: 
    >
    > I think it depends on what you want with the database. If it is just
    > selects that you want, you can create views. (You can create a view that
    > takes its data from another database.) If you want inserts, updates and
    > such things, you might take a look at the FEDERATED storage engine
    > (http://dev.mysql.com/doc/refman/5.1/en/federated-storage-engine.html).
    > Not really meant for operations on the same physical server, but I do
    > not think anybody will stop you to connect to localhost. You need to
    > have a fairly recent MySQL server though.
    >
    > Best regards,[/ref]

    It's not simple selects. For me it's not really a problem since the
    database name is stored in the config class (it's a mostly php site) but
    others have not been so consequent :-(

    Im afraid the mysql server isn't the latest version. Ive been pushing
    towards a newer version anyway .. maybe this will help.

    Imm gonna test this solution anyway just as luuk's solution

    Thx 4 ur input !

    --
    Arjen
    www.arjenkarel.nl
    Floortje Guest

  9. #9

    Default Re: Can I create an alias for a database ?

    >We have a site that needs to be frozen every year for a snapshot (older 

    I have used symlinks to database directories to relocate databases
    (primarily because of disk space issues) with MyISAM tables. This
    works OK.
     

    A possible problem here is that MySQL doesn't know that `current.whatever`
    and `0708.whatever` are the same table. This is an issue for deadlock
    detection and locking. It is probably not a problem if tables in both
    current and 0708 are used read-only.

    INSERT INTO current.whatever (SELECT * FROM `0708.whatever`);

    If these were references to the same table, MySQL would disallow
    copying a table to itself. Since it doesn't realize it if you make
    aliases with the symlink, it might see copied rows as new data to
    copy, and (assuming the table has no unique indexes) keep copying
    forever (the query would not finish until you run out of disk space,
    or it's killed).

    Gordon Guest

Similar Threads

  1. Replies: 4
    Last Post: October 3rd, 04:49 PM
  2. Replies: 3
    Last Post: September 18th, 07:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139