linux mysql ¿ª·¢»·¾³
°²×°mysql
sudo apt-get install mysql-servel-5.0 mysql-client-5.0
ÏÂÔØ°²×°¹ý³ÌÖУ¬»áÌáʾÊäÈërootÃÜÂë
°²×°CÓïÑÔ±à³Ì½Ó¿Ú£º
sudo apt-get install libmysqlclient15-dev
¸ü¶àapi ²é¿´£ºhttp://dev.mysql.com/doc/refman/5.0/en/c.html
Ïà¹ØmysqlÍ·ÎļþºÍ¿âÎļþ°²×°ÔÚ/usr/include/mysql/ºÍ/usr/lib/mysqlĿ¼
g£«£« -g xxx.cpp -I /usr/include/mysql -L /usr/lib/mysql -l mysqlclient -o xxx
#include <iostream>
#include <mysql.h>
using namespace std;
int main()
{
MYSQL *mysql;
mysql = mysql_init(0);
MYSQL_RES* result;
MYSQL_ROW row;
if(!mysql_real_connect(mysql,"localhost" , "root" , "root" , "mydb" , 3309 , NULL , 0))
{
cout<<"connect mysql server failed!"<<endl;
return -1;
}
else
{
cout<<"connect success!"<<endl;
}
mysql_set_character_set(mysql , "gbk");
string sql = "select * from test";
int status = mysql_query(mysql , sql.c_str());
if(status != 0)
{
&nb
Ïà¹ØÎĵµ£º
mysql alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×ֶεÈ
//Ö÷¼ü549830479
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ549830479
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default ......
×î½ü±ðÈËÔÚ¸øÎÒ sql Îļþʱ¼òµ¥µÄÌáÁËÏ µ¼Èë/µ¼³ö ÃüÁÔÚ´Ë»ù´¡ÉÏѧϰÁËÏ£¬×ܽᵽ myhere¡£
¹æ¶¨£º
Óû§Ãû£ºdb_user
Õʺţº db_pass
Êý¾Ý¿â£º db_name
񡜧 table_name_1, table_name_2
˵Ã÷£º һЩ²Ù×÷ÐèÒªÓÐÊʵ±µÄȨÏÞ¡£
1. ......
SQL #1: select * from uchome_feed where uid in('0',501...) order by dateline desc limit 0,50;
SQL #2: select * from uchome_feed where uid in(0,501...) order by dateline desc limit 0,50;
SQL #1 ÊÇCSDN ¸öÈË¿Õ¼ä»ñÈ¡¸öÈ˶¯Ì¬µÄSQL£¬ÊôUCHÔ°æSQL¡£
SQL #2 ÊÇÈ¥µôµ¥ÒýºÅ(SQL #1ÖкìÉ«²¿·Ö)ºóµÄSQL£¬Á½¸ ......
½ñÌìÕâô¼¤¶¯ÓÖÏëдÎÄÕµÄÔÒòÊÇMySQL5.1µÄ·¢²¼´øÀ´ÁËÉè¼Æ³¬Ç¿¶¯Á¦Êý¾Ý¿âµÄÇ¿ÓÐÁ¦µÄÎäÆ÷£¬ÈκÎMySQLµÄDBA¶¼Ó¦¸Ã¾¡¿ìѧϰ²¢Ê¹ÓÃËü¡£ÎÒ¾õµÃÈç¹ûÄܺܺõÎʹÓÃÕâ¸ö5.1°æ´øÀ´µÄÐÂÌØÐÔ£¬DBA¿ÉÒÔʹ×Ô¼º¹ÜÀíµÄVLDB£¨²»ÖªµÀʲôÊÇVLDB£¿¸æËßÄ㣬ÊǺôóºÃ´óµÄÊý¾Ý¿âµÄÒâ˼£¬Very Large DB£©»òÊý¾Ý²Ö¿âÆæ¼£°ãµÄ»ñµÃ¾Þ´óµÄÐÔÄÜÌáÉý ......
²ÎÊýƪ
×÷/ÒëÕߣºÎâ±þÎý£¬À´Ô´£ºhttp://imysql.cn¡¡£¦¡¡http://imysql.cn/blog/3208¡¡×ªÔØÇë×¢Ã÷×÷/ÒëÕߺͳö´¦£¬²¢ÇÒ²»ÄÜÓÃÓÚÉÌÒµÓÃ;£¬Î¥Õ߱ؾ¿¡£
½éÉÜ£º
¡¡¡¡InnoDB¸øMySQLÌṩÁ˾ßÓÐÌá½»£¬»Ø¹öºÍ±ÀÀ£»Ö¸´ÄÜÁ¦µÄÊÂÎñ°²È«£¨ACID¼æÈÝ£©´æ´¢ÒýÇæ¡£InnoDBËø¶¨ÔÚÐм¶²¢ÇÒÒ²ÔÚSELECTÓï¾äÌṩһ¸öOracle·ç¸ñÒ»Ö ......