Here are some websites you can learn how to code by yourself online.
1. Codecademy
2. Treehouse
3. One Month Rails
4. Hackerrank
Friday, March 7, 2014
Sunday, March 2, 2014
reclaim unused space for mysql
The problem is that mysql will not release the disk space after delete operations to an InnoDB table. That means the disk usage of mysql will not change even you delete half of the data in the database, which will be a large waste for disk usage.
There are two ways to reorganize the physical storage of table data and associated index data to reduce storage space.
1. Use OPTIMIZE TABLE or MYSQLCHECK.
2. Resize the InnoDB Tablespace (if not use innodb_file_per_table?)
References
There are two ways to reorganize the physical storage of table data and associated index data to reduce storage space.
1. Use OPTIMIZE TABLE or MYSQLCHECK.
OPTIMIZE TABLE tb1_namebut optimize table can only be performed for one table, if you want to optimize all the databases, you could either write a script to do it or use mysqlcheck command instead.
MYSQLCHECK -o --all-databases
2. Resize the InnoDB Tablespace (if not use innodb_file_per_table?)
- use mysqldump to dump all the InnoDB tables, including InnoDB tables located in MySQL database.
- stop the server.
- remove all the existing tablespace files
(
*.ibd), including theibdataandib_logfiles. Do not forget to remove*.ibdfiles for tables located in the MySQL database. - remove any .frm files for InnoDB tables.
- configure a new tablespace.
- restart the server
- import the dump files.
InnoDB engine,
it may be simpler to dump all
databases, stop the server, remove all databases and
InnoDB log files, restart the server, and
import the dump files. References
Thursday, December 26, 2013
sqlite command quick search
1. create database
sqlite3 db12. create table
create table tb1(id varchar(10), name varchar(10));3. insert data into table
insert into tb1 values('1','dude1');4. select data
select * from tb1;5. view structure
select * from sqlite_master;6. show help
.help7. list databases
.databases8. list tables
.tables9. change mode
.mode list/column/csv/html/tcl..10. change seperator
.separator ","11. change width
.width12. show headers
.header on/off13. backup database
echo '.dump' | sqlite3 db1 | gzip -c > db1.dump.gz14. rebuild database from backup
zcat db1.dump.gz | sqlite3 db215. delete table
delete table tb1;16. exit sqlite
.exit17. describe table structure
.schemaor
PRAGMA table_info(posts);
Subscribe to:
Posts (Atom)