Re: Re-creating tables
At 05:16 PM 2/24/2008, Waynn Lue wrote: That's actually why I'm dropping/recreating, because I thought the changes I have to make require multiple statements. Let me know if that's a wrong assumption, here's what I have to do. 1. drop two foreign keys from Users to Actions (in the previous example I gave). 2. expand INT to BIGINT on Users 3. expand INT to BIGINT on Actions 4. recreate two foreign keys from Users to Actions. That's four alter statements, which each require making temporary table copies, so I assumed dropping/recreating was faster. Each of your Alter statements will mean a temp table is created, the data is moved over, the changes are made, and the indexes are rebuilt. It will be 4x faster if you do it all in one Alter statement. Since the alter statement will rebuild the keys at the end, is there really a need to to drop the foreign keys or is this an InnoDb quirk? Try something like: alter table MyTable change column Users Users BigInt, change column Actions Actions BigInt; You normally would drop indexes to speed things up when loading a lot of data into the table, then rebuild the indexes after the data has been loaded. But since Alter table does this anyways, you're not accomplishing anything by doing it manually. Mike On Sat, Feb 23, 2008 at 2:42 PM, mos [EMAIL PROTECTED] wrote: At 05:55 AM 2/23/2008, Waynn Lue wrote: I have three or four different ALTER TABLE commands I need to run on a 9 million row table (related to the previous email I sent). I've tried running it before and it just takes way too long, so I was thinking the fastest way to get this done is to create new tables with the final schema, then drop the old tables and rename the new ones. There are a few ways to go about this. 1. Stop the reads/writes to the db. Use mysqldump, truncate the tables, drop the tables, recreate with the correct schema, then import it again. 2. Create a new temporary table, keep the reads and writes going, SELECT into that new table, when it catches up, turn off the reads/writes for a short period of time while I truncate/drop then rename the temporary table. 3. Use replication somehow to go from the old table to the new table (can I do that?). 4. Create a new temporary table, stop reads/writes to it, then do an INSERT INTO SELECT from the old to new table. One slight problem with choice 2 is that I don't know how to make sure that I know when the reads/writes are done. Not all the tables have an auto-increment id, so I can't just keep inserting in random ids. As an aside, if I do INSERT INTO SELECT, does it block any operations on the table that I'm SELECTing from? Thanks for any insights, Waynn Waynn, Why are you using 3 or 4 alter table commands on the same table? Each command means it will create a copy of the table, makes the changes to that, then it renames it to the correct table name and deletes the old table name. You should be able to add all 4 alter table commands in 1 Alter Table statement, just by putting a , between the alter specifications. See the syntax in the manual: http://dev.mysql.com/doc/refman/5.0/en/alter-table.html This means the table gets rebuilt only once and not 4 times! Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Re-creating tables
The problem here though is that there is no MyTable. There are two separate tables, Users and Actions, and I can't alter both of them in the same statement, as far as I know. As a result, when I alter just Users, that fails because there's an FK between Users and Actions and the type of the two columns is now different. On Mon, Feb 25, 2008 at 7:50 AM, mos [EMAIL PROTECTED] wrote: At 05:16 PM 2/24/2008, Waynn Lue wrote: That's actually why I'm dropping/recreating, because I thought the changes I have to make require multiple statements. Let me know if that's a wrong assumption, here's what I have to do. 1. drop two foreign keys from Users to Actions (in the previous example I gave). 2. expand INT to BIGINT on Users 3. expand INT to BIGINT on Actions 4. recreate two foreign keys from Users to Actions. That's four alter statements, which each require making temporary table copies, so I assumed dropping/recreating was faster. Each of your Alter statements will mean a temp table is created, the data is moved over, the changes are made, and the indexes are rebuilt. It will be 4x faster if you do it all in one Alter statement. Since the alter statement will rebuild the keys at the end, is there really a need to to drop the foreign keys or is this an InnoDb quirk? Try something like: alter table MyTable change column Users Users BigInt, change column Actions Actions BigInt; You normally would drop indexes to speed things up when loading a lot of data into the table, then rebuild the indexes after the data has been loaded. But since Alter table does this anyways, you're not accomplishing anything by doing it manually. Mike On Sat, Feb 23, 2008 at 2:42 PM, mos [EMAIL PROTECTED] wrote: At 05:55 AM 2/23/2008, Waynn Lue wrote: I have three or four different ALTER TABLE commands I need to run on a 9 million row table (related to the previous email I sent). I've tried running it before and it just takes way too long, so I was thinking the fastest way to get this done is to create new tables with the final schema, then drop the old tables and rename the new ones. There are a few ways to go about this. 1. Stop the reads/writes to the db. Use mysqldump, truncate the tables, drop the tables, recreate with the correct schema, then import it again. 2. Create a new temporary table, keep the reads and writes going, SELECT into that new table, when it catches up, turn off the reads/writes for a short period of time while I truncate/drop then rename the temporary table. 3. Use replication somehow to go from the old table to the new table (can I do that?). 4. Create a new temporary table, stop reads/writes to it, then do an INSERT INTO SELECT from the old to new table. One slight problem with choice 2 is that I don't know how to make sure that I know when the reads/writes are done. Not all the tables have an auto-increment id, so I can't just keep inserting in random ids. As an aside, if I do INSERT INTO SELECT, does it block any operations on the table that I'm SELECTing from? Thanks for any insights, Waynn Waynn, Why are you using 3 or 4 alter table commands on the same table? Each command means it will create a copy of the table, makes the changes to that, then it renames it to the correct table name and deletes the old table name. You should be able to add all 4 alter table commands in 1 Alter Table statement, just by putting a , between the alter specifications. See the syntax in the manual: http://dev.mysql.com/doc/refman/5.0/en/alter-table.html This means the table gets rebuilt only once and not 4 times! Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Re-creating tables
That's actually why I'm dropping/recreating, because I thought the changes I have to make require multiple statements. Let me know if that's a wrong assumption, here's what I have to do. 1. drop two foreign keys from Users to Actions (in the previous example I gave). 2. expand INT to BIGINT on Users 3. expand INT to BIGINT on Actions 4. recreate two foreign keys from Users to Actions. That's four alter statements, which each require making temporary table copies, so I assumed dropping/recreating was faster. On Sat, Feb 23, 2008 at 2:42 PM, mos [EMAIL PROTECTED] wrote: At 05:55 AM 2/23/2008, Waynn Lue wrote: I have three or four different ALTER TABLE commands I need to run on a 9 million row table (related to the previous email I sent). I've tried running it before and it just takes way too long, so I was thinking the fastest way to get this done is to create new tables with the final schema, then drop the old tables and rename the new ones. There are a few ways to go about this. 1. Stop the reads/writes to the db. Use mysqldump, truncate the tables, drop the tables, recreate with the correct schema, then import it again. 2. Create a new temporary table, keep the reads and writes going, SELECT into that new table, when it catches up, turn off the reads/writes for a short period of time while I truncate/drop then rename the temporary table. 3. Use replication somehow to go from the old table to the new table (can I do that?). 4. Create a new temporary table, stop reads/writes to it, then do an INSERT INTO SELECT from the old to new table. One slight problem with choice 2 is that I don't know how to make sure that I know when the reads/writes are done. Not all the tables have an auto-increment id, so I can't just keep inserting in random ids. As an aside, if I do INSERT INTO SELECT, does it block any operations on the table that I'm SELECTing from? Thanks for any insights, Waynn Waynn, Why are you using 3 or 4 alter table commands on the same table? Each command means it will create a copy of the table, makes the changes to that, then it renames it to the correct table name and deletes the old table name. You should be able to add all 4 alter table commands in 1 Alter Table statement, just by putting a , between the alter specifications. See the syntax in the manual: http://dev.mysql.com/doc/refman/5.0/en/alter-table.html This means the table gets rebuilt only once and not 4 times! Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re-creating tables
I have three or four different ALTER TABLE commands I need to run on a 9 million row table (related to the previous email I sent). I've tried running it before and it just takes way too long, so I was thinking the fastest way to get this done is to create new tables with the final schema, then drop the old tables and rename the new ones. There are a few ways to go about this. 1. Stop the reads/writes to the db. Use mysqldump, truncate the tables, drop the tables, recreate with the correct schema, then import it again. 2. Create a new temporary table, keep the reads and writes going, SELECT into that new table, when it catches up, turn off the reads/writes for a short period of time while I truncate/drop then rename the temporary table. 3. Use replication somehow to go from the old table to the new table (can I do that?). 4. Create a new temporary table, stop reads/writes to it, then do an INSERT INTO SELECT from the old to new table. One slight problem with choice 2 is that I don't know how to make sure that I know when the reads/writes are done. Not all the tables have an auto-increment id, so I can't just keep inserting in random ids. As an aside, if I do INSERT INTO SELECT, does it block any operations on the table that I'm SELECTing from? Thanks for any insights, Waynn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Re-creating tables
At 05:55 AM 2/23/2008, Waynn Lue wrote: I have three or four different ALTER TABLE commands I need to run on a 9 million row table (related to the previous email I sent). I've tried running it before and it just takes way too long, so I was thinking the fastest way to get this done is to create new tables with the final schema, then drop the old tables and rename the new ones. There are a few ways to go about this. 1. Stop the reads/writes to the db. Use mysqldump, truncate the tables, drop the tables, recreate with the correct schema, then import it again. 2. Create a new temporary table, keep the reads and writes going, SELECT into that new table, when it catches up, turn off the reads/writes for a short period of time while I truncate/drop then rename the temporary table. 3. Use replication somehow to go from the old table to the new table (can I do that?). 4. Create a new temporary table, stop reads/writes to it, then do an INSERT INTO SELECT from the old to new table. One slight problem with choice 2 is that I don't know how to make sure that I know when the reads/writes are done. Not all the tables have an auto-increment id, so I can't just keep inserting in random ids. As an aside, if I do INSERT INTO SELECT, does it block any operations on the table that I'm SELECTing from? Thanks for any insights, Waynn Waynn, Why are you using 3 or 4 alter table commands on the same table? Each command means it will create a copy of the table, makes the changes to that, then it renames it to the correct table name and deletes the old table name. You should be able to add all 4 alter table commands in 1 Alter Table statement, just by putting a , between the alter specifications. See the syntax in the manual: http://dev.mysql.com/doc/refman/5.0/en/alter-table.html This means the table gets rebuilt only once and not 4 times! Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Creating Tables/Keys from PowerDesigner Sql
Well, that would depend if the SQL script generated by your designer is compatible with MySQL, some type names may be different. Good Luck! --- [EMAIL PROTECTED] wrote: I generated an SQL script of my datamodel in PowerDesigner which I'd like to import into mySql to create my tables, keys, etc. How do I accomplish this? Thanks, Jason E. Brawner - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Creating tables in mysql
Hello, Now i am struck up with one problem...When i am trying to create a table in the mysql database it is giving this error...Can anyone plese help me how to rectify this problem.. ERROR 1: Can't create/write to file './dbase/rr.frm' (Errcode: 13) My mysql database name is dbase and my table name is rr -Uma - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number
powlow wrote: first posting to the list so hello. My name is Paulo. I live and work in lisbon, portugal. question : i want to create a table each month. want to call it somehting like 012001 for January 2001. mysql does not seem to allow this. Jan2001 is fine. d122001 is also fine. is it not possible to create tables with only a number as the name? is there a way round this? Most RDBMS do not allow columns or tables to start with a number. I know that does not help your situation but it is not unusual. Also, why don't you put a prefix on the table name that indicates what it is going to hold? Another developer that sees a table called '012001' is not going to know what the heck the table is. But a name like 'custorders_200101' is more informative and gets around your problem. (I would always name dates in the order of year, month, day. Then you can sort and compare them with ease in just about any language .) --Bill - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number
At 6:39 PM +0100 9/14/01, powlow wrote: Hi, first posting to the list so hello. My name is Paulo. I live and work in lisbon, portugal. question : i want to create a table each month. want to call it somehting like 012001 for January 2001. mysql does not seem to allow this. Jan2001 is fine. d122001 is also fine. is it not possible to create tables with only a number as the name? is there a way round this? Yes, it's possible, but it's a bad idea: - numbers are hard to recognize as names - you'll have to use a special syntax *every* time you refer to the table Anyway, if you want to do this, you must enclose the name in backquotes: CREATE TABLE `1` (i INT); DROP TABLE `1`; If I were you, I'd just prefix the numbers with a character, e.g., t012001, t022001, etc. 2 days of work wasted here!! thanks for any help -paulo -- Paul DuBois, [EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number THIS IS A BUG
FYI .. I just tried this my self with CREATE TABLE 010823 (tstamp TIMESTAMP (14) , name VARCHAR (10) not null , PRIMARY KEY (tstamp), INDEX (name)) and got ... MySQL said: You have an error in your SQL syntax near '010823 (tstamp TIMESTAMP (14) , name VARCHAR (10) not null , PRIMARY KEY (tst' at line 1 The manual specificaly states in section 7.1.5 ... Table Any character that is allowed in a file name, except `/' or `.'. SO this does seem like a bug .. hope MySql guys see this. I have looked but can't find anything about how to contact in case of bugs .. Friday, September 14, 2001, 10:39:35 AM, you wrote: p Hi, p first posting to the list so hello. My name is Paulo. I live and work in p lisbon, portugal. p question : i want to create a table each month. want to call it somehting p like 012001 for January 2001. mysql does not seem to allow this. Jan2001 is p fine. d122001 is also fine. is it not possible to create tables with only a p number as the name? is there a way round this? -- Best regards, Igbarmailto:[EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number THIS IS A BUG
Hi, SO this does seem like a bug .. hope MySql guys see this. I have looked but can't find anything about how to contact in case of bugs .. mail to [EMAIL PROTECTED] :-) Rgds, Indrek -- For technical support contracts, goto https://order.mysql.com/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Indrek Siitan [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, The Web Guru /_/ /_/\_, /___/\___\_\___/ Tallinn, Estonia ___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number
Hello, On Fri, 14 Sep 2001, powlow wrote: fine. d122001 is also fine. is it not possible to create tables with only a number as the name? is there a way round this? mysql CREATE TABLE `123` (id INT); Query OK, 0 rows affected (0.00 sec) mysql show tables; ++ | Tables_in_test | ++ | 123| 2 days of work wasted here!! 2 minutes to test all kin of quotes :-) Andreas Karl Wittwer Phone: +49-7052-92206 FAX: +49-7052-92208 Mobil: +49-172-542 541 4 SQL, DATABASE, MYSQL - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number THIS IS A BUG
At 11:17 AM -0700 9/14/01, Igbar Foosenhopper wrote: FYI .. I just tried this my self with CREATE TABLE 010823 (tstamp TIMESTAMP (14) , name VARCHAR (10) not null , PRIMARY KEY (tstamp), INDEX (name)) and got ... MySQL said: You have an error in your SQL syntax near '010823 (tstamp TIMESTAMP (14) , name VARCHAR (10) not null , PRIMARY KEY (tst' at line 1 The manual specificaly states in section 7.1.5 ... Table Any character that is allowed in a file name, except `/' or `.'. SO this does seem like a bug .. hope MySql guys see this. I have looked but can't find anything about how to contact in case of bugs .. If you had read two more paragraphs, you would see: Note that if the identifier is a restricted word or contains special characters you must always quote it with ` when you use it: SELECT * from `select` where `select`.id 100; -- Paul DuBois, [EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: creating tables using a number THIS IS A BUG
indrek siitan writes: Hi, SO this does seem like a bug .. hope MySql guys see this. I have looked but can't find anything about how to contact in case of bugs .. mail to [EMAIL PROTECTED] :-) er, [EMAIL PROTECTED] -- For technical support contracts, visit https://order.mysql.com/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Matt Wagner [EMAIL PROTECTED] / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Herr Direktor /_/ /_/\_, /___/\___\_\___/ Hopkins, Minnesota USA ___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: creating tables from the shell
Hi, mysql -vvv samp_db create_member.sql should tell what commands mysql is executing. Regards Quentin -Original Message- From: Michael Tuminello [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 7 February 2001 10:05 To: [EMAIL PROTECTED] Subject: creating tables from the shell Hey - sorry for being too much of a pinhead to figure this out, but the server is really not giving me too many clues to work with. I'm trying to execute commands from the shell to create new tables (I'm walking through the new riders book). the book says % mysql samp_db create_member.sql for me, for whatever reason, mysql will not execute except from its root directory. so I'm doing % ./bin/mysql samp_db ./var/mysql/create_member.sql (the book also doesn't tell you where to put the executible scripts, so I stuck them in the data directory) can anyone tell me why this isn't working? it seems to execute (no error), but nothing happens. Also, can anyone tell me if there is a way to get the server to tell you a little more about why things don't work? I could use some help debugging, and the log entries are pithy, to say the least. thanks in advance- MT - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php The information contained in this email is privileged and confidential and intended for the addressee only. If you are not the intended recipient, you are asked to respect that confidentiality and not disclose, copy or make use of its contents. If received in error you are asked to destroy this email and contact the sender immediately. Your assistance is appreciated. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: creating tables from the shell
Thanks for the responses. Both those comments will no doubt help me out next time. this time around, pathetically enough, it was bad line breaks due to the fact I decompressed it on a mac and then uploaded it. how embarasskin. MT - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php