MySQL³£ÓòÙ×÷»ù±¾²Ù×÷
¹Ø¼ü×Ö: mysql³£ÓòÙ×÷»ù±¾²Ù×÷
MySQL³£ÓòÙ×÷»ù±¾²Ù×÷£¬ÒÔ϶¼ÊÇMySQL5.0ϲâÊÔͨ¹ýÊ×ÏÈ˵Ã÷Ï£¬¼ÇסÔÚÿ¸öÃüÁî½áÊøʱ¼ÓÉÏ£»£¨·ÖºÅ£©
1.µ¼³öÕû¸öÊý¾Ý¿â
mysqldump -u Óû§Ãû -p --default-character-set=latin1 Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû(Êý¾Ý¿âĬÈϱàÂëÊÇlatin1)
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.µ¼³öÒ»¸ö±í
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû ±íÃû> µ¼³öµÄÎļþÃû
mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3.µ¼³öÒ»¸öÊý¾Ý¿â½á¹¹
mysqldump -u wcnc -p -d –add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d ûÓÐÊý¾Ý –add-drop-table ÔÚÿ¸öcreateÓï¾ä֮ǰÔö¼ÓÒ»¸ödrop table
4.µ¼ÈëÊý¾Ý¿â
³£ÓÃsource ÃüÁî
½øÈëmysqlÊý¾Ý¿â¿ØÖÆ̨£¬
Èçmysql -u root -p
mysql>use Êý¾Ý¿â
È»ºóʹÓÃsourceÃüÁºóÃæ²ÎÊýΪ½Å±¾Îļþ(ÈçÕâÀïÓõ½µÄ.sql)
mysql>source d:wcnc_db.sql
Ò»¡¢Æô¶¯ÓëÍ˳ö
1¡¢½øÈëMySQL£ºÆô¶¯MySQL Command Line Client£¨MySQLµÄDOS½çÃ棩£¬Ö±½ÓÊäÈ밲װʱµÄÃÜÂë¼´¿É¡£´ËʱµÄÌáʾ·ûÊÇ£ºmysql>
2¡¢Í˳öMySQL£ºquit»òexit
¶þ¡¢¿â²Ù×÷
1¡¢¡¢´´½¨Êý¾Ý¿â
ÃüÁcreate database <Êý¾Ý¿âÃû>
ÀýÈ磺½¨Á¢Ò»¸öÃûΪxhkdbµÄÊý¾Ý¿â
mysql> create database xhkdb;
2¡¢ÏÔʾËùÓеÄÊý¾Ý¿â
ÃüÁshow databases £¨×¢Ò⣺×îºóÓиös£©
mysql> show databases;
3¡¢É¾³ýÊý¾Ý¿â
ÃüÁdrop database <Êý¾Ý¿âÃû>
ÀýÈ磺ɾ³ýÃûΪ xhkdbµÄÊý¾Ý¿â
mysql> drop database xhkdb;
4¡¢Á¬½ÓÊý¾Ý¿â
ÃüÁ use <Êý¾Ý¿âÃû>
ÀýÈ磺Èç¹ûxhkdbÊý¾Ý¿â´æÔÚ£¬³¢ÊÔ´æÈ¡Ëü£º
mysql> use xhkdb;
ÆÁÄ»Ìáʾ£ºDatabase changed
5¡¢µ±Ç°Ñ¡Ôñ£¨Á¬½Ó£©µÄÊý¾Ý¿â
mysql> select database();
6¡¢µ±Ç°Êý¾Ý¿â°üº¬µÄ±íÐÅÏ¢£º
mysql> show tables; £¨×¢Ò⣺×îºóÓиös£©
Èý¡¢±í²Ù×÷£¬²Ù×÷֮ǰӦÁ¬½Óij¸öÊý¾Ý¿â
1¡¢½¨±í
ÃüÁcreate table <±íÃû> ( <×Ö¶ÎÃû1> <ÀàÐÍ1> [,..<×Ö¶ÎÃûn> <ÀàÐÍn>]);
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
2¡¢»ñÈ¡±í½á¹¹
ÃüÁ desc ±íÃû£¬»òÕßshow columns from ±íÃû
mysql>DESCRIBE MyClass
mysql&g
Ïà¹ØÎĵµ£º
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£¬Á½¸ ......
²ÎÊýƪ
×÷/ÒëÕߣºÎâ±þÎý£¬À´Ô´£ºhttp://imysql.cn¡¡£¦¡¡http://imysql.cn/blog/3208¡¡×ªÔØÇë×¢Ã÷×÷/ÒëÕߺͳö´¦£¬²¢ÇÒ²»ÄÜÓÃÓÚÉÌÒµÓÃ;£¬Î¥Õ߱ؾ¿¡£
½éÉÜ£º
¡¡¡¡InnoDB¸øMySQLÌṩÁ˾ßÓÐÌá½»£¬»Ø¹öºÍ±ÀÀ£»Ö¸´ÄÜÁ¦µÄÊÂÎñ°²È«£¨ACID¼æÈÝ£©´æ´¢ÒýÇæ¡£InnoDBËø¶¨ÔÚÐм¶²¢ÇÒÒ²ÔÚSELECTÓï¾äÌṩһ¸öOracle·ç¸ñÒ»Ö ......
MySQL Data Type
Oracle Data Type
BIGINT
NUMBER(19, 0)
BIT
RAW
BLOB
BLOB, RAW
CHAR
CHAR
DATE
DATE
DATETIME
DATE
DECIMAL
FLOAT (24)
DOUBLE
FLOAT (24)
DOUBLE PRECISION
FLOAT (24)
ENUM
VARCHAR2
FLOAT
FLOAT
INT
NUMBER(10, 0)
INTEGER
NUMBER(10, 0)
LONGBLOB
BLOB, RAW
LONGTEX ......
¸ñʽΪ2008-06-16
²éѯ³öµ±ÌìÊý¾Ý£º
SELECT * from `table` WHERE date(ʱ¼ä×Ö¶Î) = curdate();
²éѯ³öµ±ÔÂ×ֶΣº
SELECT *
from `table`
WHERE month( ʱ¼ä×Ö¶Î) = month( now( ) ) ;
ʱ¼ä¸ñʽΪ1219876…… UNIXʱ¼ä£¬Ö»ÒªÓ¦ÓÓfrom_UNIXTIME( )”º¯Êý
ÀýÈç²éѯµ±Ô£º
SELECT ......