MySQLѧϰ
»ù±¾µÄMySQLÓï¾äºÜ¼òµ¥£¬ÕâÀïÖ÷Ҫ̸̸һЩÈÝÒ×ÒÅÍüµÄ¡£
1.ÈçºÎÉèÖÃ×ֶεÝÔö
create table tb_User(Id int auto_increment
not null primary key,UserName varchar(50),Password varchar(20));
2.²é¿´±í½á¹¹
desc tb_User;
3.ÈçºÎÐ޸ıí½á
ÖØÃüÃû±í£ºalter table tb_User rename
tb_UserInfo;
Ìí¼ÓÒ»ÁУºalter table tb_User add
(Date datetime);
ɾ³ýÒ»ÁУºalter table tb_User drop
column Date;
ÐÞ¸ÄÒ»ÁÐÊôÐÔ£ºalter table tb_User change
UserName UserName varchar(50) not null;£¨Óô˷½·¨¿ÉÒÔÖØÃüÃûÒ»ÁУ©
Ìí¼ÓÖ÷¼ü£ºalter table tb_User add primary key(Ö÷¼ü×Ö¶Î);
Ìí¼ÓË÷Òý£ºalter table tb-User add index(×Ö¶ÎÃû);
4.ÈçºÎ±¸·ÝºÍµ¼ÈëÊý¾Ý¿â
Õâ¸öÎÊÌâÓм¸ÖÖ·½·¨£¬µ«ÊÇÎÒ¸öÈ˸üϲ»¶mysqldump£¬¾Ù¸öÀý×ÓÎÒÏÖÔÚÓÐÒ»¸öÊý¾Ý¿âdb_cmj
ÏÖÔÚÒªÏ뽫Õâ¸öÊý¾Ý¿â¸½¼Óµ½Áíһ̨µçÄÔÉÏ£¬Èç¹ûÁ½Ì¨µçÄÔÍøÂçͨµÄ»°¿ÉÒÔͨ¹ýmysqldumpÃüÁîÖ±½ÓÒ»²¿Íê³É£¬µ«ÊÇÕâÖÖÇé¿öҪעÒâmysql°æ±¾ÎÊÌâ¡£ÎÒÕâÀïÌṩһÖÖͨÓõķ½·¨£¬Ò²ÊǸüÈÝÒ×Àí½âµÄ£ºÊÔÏëÒ»ÏÂÈç¹ûÄãÄܹ»½«ÏÖÔÚÎÒÕą̂µçÄÔÉϵÄdb_cmjÖÐËùÓеÄÐÅÏ¢¶¼±ä³ÉsqlÓï¾ä£¬²¢±£´æµ½Ò»¸öÎļþÖУ¬È»ºóÄÃ×ÅÕâ¸öÎļþµ½Áíһ̨»úÆ÷ÉÏÖ´ÐÐÒÔϲ»¾Í¿ÉÒÔÁËÂð¡£
¾ßÌåÔõô×öÄØ£¿
ÃüÁîÐÐÖÐÊäÈ룺mysqldump -uroot -p db_cmj > db_cmj.sql [»Ø³µ]
ÊäÈëÃÜÂë
¾Í»áÉú³ÉÒ»¸ödb_cmj.sqlÎļþ£¬ÀïÃæ°üº¬ËùÓÐÄãµÄÊý¾Ý¿âÐÅÏ¢£¬Õâ¸öÎļþºÃÏñÔÚC:\Documents and Settings\AdministratorÏÂ
È»ºóÄõ½Õâ¸öÎļþµ½Áíһ̨»úÆ÷ÉÏ£¬ÀýÈç·Åµ½ÄÇ̨»úÆ÷µÄcÅ̸ùĿ¼£¬´ÓÃüÁîÐнøÈëmysqlºóÖ´ÐÐdb_cmj.sqlÖÐsqlÓï¾ä£¬ÕâÀïÎÒÃÇÓÃÅú´¦Àí
Ö´ÐУºsource C:\db_cmj.sql[»Ø³µ]
¾Í»á·¢ÏÖÄãÒѾ³É¹¦½«Êý¾Ý¿â¿½±´µ½Õą̂»úÆ÷ÉÏÁË£¬¼È·½±ãÓÖÖ±¹Û£¬×îÖ÷ÒªÊÇ¿ÉÒԵõ½sqlÓï¾ä£¬Õâ²ÅÊDZ¾ÖÊ¡£
×¢Ò⣺Õâ¸ö¹ý³Ì×î³£¼ûµÄÒ»¸öÎÊÌâ¾ÍÊÇ£¬±àÂë²»ÕýÈ·£¬ÎÒÃÇÏëÏóµÄÊǿ϶¨ÓõÄÊÇĬÈϱàÂëutf-8,ËùÒÔÔÚÓÃmysqldumpʱ¾Í²»ÓÃÖ¸¶¨±àÂ뷽ʽ£¬¶øÊÂʵÉÏÎÒÃÇÒªÖ¸¶¨£¬¶øÇÒÒªÖƶ¨³Élatin1£¬Ò²¾ÍÊÇÃüÁî¸ÄΪ£ºmysqldump -uroot -p db_cmj > db_cmj.sql --default-character-set=latin1¡£Õâ¸öÎÊÌâÍøÉÏÓкܶ࣬µ«ÊÇ´ó¶àÊýûÓиø³öºÜºÃµÄ½âÊÍ¡£
³£¼ûÎÊÌ⣺
1.ÈçºÎ²åÈ뵱ǰÈÕÆÚ
insert into tb_User(UserName ,Password,Date) vlaues('cmj','123',Now());
2.×Ö¶ÎΨһÐÔ
×Ö¶ÎΨһÐÔÓõÄÊÇunique¡£
ÍØÕ¹£º
1.ÈçºÎÀûÓÃMySQLʵÏÖ·ÖÒ³
(¼ÙÉèÒ³ÓÐÎåÌõ¼Ç¼£¬ÏÖÔÚÏÔʾ
Ïà¹ØÎĵµ£º
¸ñʽΪ2008-06-16
²éѯ³öµ±ÌìÊý¾Ý£º
SELECT * from `table` WHERE date(ʱ¼ä×Ö¶Î) = curdate();
²éѯ³öµ±ÔÂ×ֶΣº
SELECT *
from `table`
WHERE month( ʱ¼ä×Ö¶Î) = month( now( ) ) ;
ʱ¼ä¸ñʽΪ1219876…… UNIXʱ¼ä£¬Ö»ÒªÓ¦ÓÓfrom_UNIXTIME( )”º¯Êý
ÀýÈç²éѯµ±Ô£º
SELECT ......
×òÌ죬ÎÒͻȻÏë°ÑÒ»¸öÊý¾Ý¿âÀïµÄÿ¸ö±í£¬ÒÔ¼°Ã¿¸ö±íµÄ·Ç¿Õ×ܼͼÊý´æÔÚÁíÒ»¸ö±íÀïÃæ¡£
Ê×ÏÈ£¬´´½¨ÁËÒ»¸ö´æ·ÅÊý¾ÝµÄ±í£º
create table tables
(
name varchar(50),
number int
);
insert into tables select table_name from information_schema.tables where table_shema = 'test';
µ«ÊDz»ÖªµÀÓÐûÓз½·¨£¬½«·Ç¿ÕµÄ ......
MSSQL:select Right(sys.fn_VarBinToHexStr(hashbytes('MD5', '123456')),32)
MSSQL16λ:select Right(sys.fn_VarBinToHexStr(hashbytes('MD5', '123456')),16)
MySQL:select md5('123456')
.NET:string ½á¹û×Ö·û´®=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFil ......
1¡¢ÔÚmysql Êý¾Ý¿âÖУ¬“2009-09-15 00£º00£º00”ת»¯ÎªÁÐΪ³¤ÕûÐ͵ĺ¯Êý£º
select unix_timstamp("2009-09-15 00£º00£º00")*1000,
ÕâÀïҪעÒ⣬mysqlÊý¾Ý¿âÖеij¤ÕûÐÍ£¬±ÈjavaÖеij¤ÕûÐÍÉÙÁËÃëºóÃæµÄºÁÃëÊý£¬ËùÒÔÒª³ËÒÔ1000£¬ÕâÑùÖ»Óм¸ºÁÃëÖ®²î
2¡¢ÔÚmysqlÊý¾Ý¿âÖУ¬“1252999488000”£ ......
Ò»¡¢ÉèÖÃÊý¾Ý¿â±àÂë
°²×°mysqlʱ¿ÉÑ¡Ôñ±àÂ룬Èç¹ûÒѾ°²×°¹ý£¬¿ÉÒÔ¸ü¸ÄÎļþmy.ini(´ËÎļþÔÚmysqlµÄ°²×°Ä¿Â¼ÏÂ)ÖеÄÅäÖÆÒԴﵽĿµÄ£»´ò¿ªÎļþÕÒµ½Á½´¦£º
[client]
port=3306
[mysql]
default-character-set=gb2312
# The default character set that will be used when a new
schema or table is
# created and
n ......