ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[­ì³Ð] MySQL ·s¤â¤W¸ô

[­ì³Ð] MySQL ·s¤â¤W¸ô

¥H¤U¤å³¹¬°¤p»x¯¸ªø©Ò´£¦@!

¤@¡BMySQL²¤¶

MySQL¬O¤@­Ó¤p¥©ÆFÄnªºDatabase¦øªA¾¹³n¥ó¡A¹ï©ó¤¤¡B¤p«¬À³¥Î¨t²Î¬O«D±`²z·Qªº¡C°£¤F¤ä«ù¼Ð·ÇªºANSI SQL»y¥y¥~¡A³Ì­«­nªº¬O¡A¥¦ÁÙ¤ä«ù¦hºØ¥­¥x¡A¦Ó¦bUnix/Linux¨t²Î¤W¡AMySQL¤ä«ù¦h½uµ{°õ¦æ¤è¦¡¡A±q¦Ó¯àÀò±o¬Û·í¦nªº©Ê¯à¡C¥¦©M«e¨â­Ó³n¥ó¤@¼Ë¡A¬OÄÝ©ó¶}©ñ·½­ì©l½X³nÊ^¡C

¤G¡BMySQLªº¦w¸Ë(«üWindowsª©¥»)

±N¤U¸ü«áªº¤å¥ó¸ÑÀ£¡A¨ì¤@­Ó¥Ø¿ý¡A°õ¦æ Setupµ{§Ç¡A·|´£¥Ü¾ã­Ó¦w¸Ëªº¹Lµ{¡C¥¦ Default ¦w¸Ë¨ì c:/mysql¤U¡A¦pªG­n¦w¸Ë¨ì¨ä¥¦¥Ø¿ý¤UÁÙ¦³§ï°Ê¤@¨ÇªF¦è¡A§@¬°ªì¾ÇªÌ¡A¥i¥H¥ý¤£ºÞ¡A¥HDefault c:mysql¤U¡A¦pªG­n¦w¸Ë¨ì¨ä¥¦¥Ø¿ý¤UÁÙ¦³§ï°Ê¤@¨ÇªF¦è¡A§@¬°ªì¾ÇªÌ¡A¥i¥H¥ý¤£ºÞ¡A¥H Default ªº¥Ø¿ý¦w¸Ë¡C¦n¤F¡A¦w¸Ë«á¡A¶i¤Jc:mysqlbin¥Ø¿ý¤U¡A°õ¦æmysqld-shareware.exe¤å¥ó

¦bWin98¤Uª½±µ°õ¦æ¡A¥¿±`±¡ªp¤U¡A¨S¦³¤°»ò´£¥Ü«H®§
¦bNT¤U¥i¥H¿é¤J¡Jmysqld-shareware --install ±Ò°Ê¸ÓªA°È
±µµÛ¡A¿é¤J mysql ¡A¥¿±`±¡ªp¤U·|¥X²{´X¦æ´£¥Ü«H®§¨Ã¥X²{¤U´£¥Ü²Å¸¹¡J

mysql>

¨ì¦¹¡A§A¤w¸g¦¨¥¦w¸Ë¤FMySQL¡C

¤T¡B³]©wMySQL¥Î¤á±K½X

MySQLDatabaseªºDefault ¥Î¤á¦W¬°¡§root¡¨(MS SQL Server ªº sa ¬Û¦ü)¡A±K½X Default ¬°ªÅ¡C¦bDOS´£¥Ü²Å¡]ª`·N¡A¤£¬Omysql´£¥Ü²Å¡^¤U¿é¤J

c:mysqlbin>¡§mysqladmin -u root -p password adminpassword

¦^¨®«á·|´£¥Ü§A¿é¤J­ì¨Óªº±K½X¡A¥Ñ©ó­ì¨Ó±K½X¬°ªÅ¡Aª½±µ¦^¨®¡Aroot¥Î¤áªº±K½X«K§ï¬°¡§adminpassword¡¨¤F¡C

¥|¡B²³æ¨Ï¥ÎMySQLDatabase

1.Åã¥Ü MySQLªºDatabase(ª`·N¡J¦b¸Ó¤åªº¥H«á³¡¤À¡A¦pªG¨S¦³´£¥Ü¡A¿é¤Jªº©R¥O³£¬O¦bmysql´£¥Ü²Å¤U)

show databases

2.¥´¶}¤@­ÓDatabase

use test

¨ä¤¤¡Atest¬°Database¦WºÙ

3.Åã¥Ü¤@­ÓDatabase¤¤©Ò¦³table ¡]¥²¶·¥ý¥´¶}¤@­ÓDatabase¡^

show tables

go

4. ¥Hroot¨­¥÷«Ø¥ß¤@­ÓDatabase(¦bDOS´£¥Ü²Å¸¹¤U)

mysqladmin -u root -p password adminpassword create gsbook

±µµÛ·|´£¥Ü§A¿é¤J±K½X¡C¦]¬°¡A§Ú­Ìªº¥Øªº¬O°µ¤@­Ó¯d¨¥ªO¡A§Ú¦b³o¸Ì±N Databaseªº¦WºÙ©R¦W¬°¡§guestbook¡¨¡C

5.¦bDatabase¤¤¥[¤Jguestbook table

create table guestbook(id int not null auto_increment,primary key(id),nickname varchar(30),email varchar(30),homepage varchar(30),note text,w_time datetime)

6.³Ì¦n¥Î phpMyAdmin ¨ÓºÞ²z¸ê®Æ®w

¦^´_ 1# Min

«Ø¥ß¸ê®Æªí

¤ñ¦p §Ú­Ì¤µ¤Ñ­n°µ°O¿ý¾Ç¥Íªº¦¨ÁZ
¨º§Ú­Ì¬O¤£¬O­n¥ý§â­n¦Ò¸Õªº¬ì¥Ø­q¦n
¤~¤è«K°µªí®æÄæ¦ì
´N¹³³o¼Ë

¾Ç¥Í­^¤å¤Î°ê¤å¦¨ÁZ¸ê®Æ°O¿ý
®y¸¹
©m¦W
­^¤å
°ê¤å

1
³¯ªü«ó
50
50

2
§º¤p·ì
51
49

3
³s¤£¾Ô
null
null

³o¼Ë´N¬O¤@­Ó§¹¾ãªº¸ê®Æªí¤F!

¦n¤F¸Ñ»¡¤@¤U:
³o¬O«ü¸ê®Æªí¦WºÙ

³o¬O«ü¸ê®ÆªíÄæ¦ì¦WºÙ

³o¬O«ü¸ê®ÆÄæ¦ì¤º®e

·§©À´N¬O³o¼Ë¤l!
¨º§Ú­Ì¹ê§@¤@¤U~
mysql>use student
mysql>create table EnAndCn(
mysql>ID int(2) notnull default '0',
mysql>name char(20) notnull default '',
mysql>english int(3) default null,
mysql>chinese int(3) default null
mysql>);

ok! ³o¼Ë´N«Ø¥ß¦n¹³¤W¦C¤@¼ËªºÄæ¦ì¤F!
´Nµ¥µÛ¤j®a¿é¤JÄæ¦ì¤º®e¤F
¦A¸Ñ»¡¤@¤U:
1.[ create table table¦WºÙ ] ³o¬O¸ê®Æ®w«Ø¥ßªº»yªk
{ ¦b¤j¬A¸¹¤¤ªº¤º®eªí¥Ü ¸ê®Æªíªº®æ¦¡¤ÎÄæ¦ì}
2.¤@­Ó°ò¥»ªºÄæ¦ì»Ý­n¦³¥H¤Uªº¤@¨Ç±ø¥ó
[ Äæ¦ì¦WºÙ, ®æ¦¡( ¤j¤p) , ¥i§_¬°¥¼ª¾¼Æ , ¹w³]­È ,ªþ¥[³W«h ]
ID int (2) notnull default '0' ²¤
3.int(¥Nªí¼Æ¦r)¤Îchar(¦r¦ê)ªº ³o¤@­Ó³¡¥÷¥H«á¦A½Í

³o¼Ë´N§¹¦¨¤@­Ó¸ê®Æªíªº«Ø¥ß¤F

¦³ÂI½ÆÂø: ¦ý¬O·Q²M·¡´N¬O¤F
¦A¨Ó¦p¦ó§R°£³o¤@­Ó¸ê®Æªí©O?

mysql>drop table EnAndCn;

»yªk: [ DROP TABLE ¸ê®Æ®w¦WºÙ ]

TOP

¥»©«³Ì«á¥Ñ PD961A ©ó 2010-5-18 12:46 ½s¿è
¦^´_  Min

«Ø¥ß¸ê®Æªí

¤ñ¦p §Ú­Ì¤µ¤Ñ­n°µ°O¿ý¾Ç¥Íªº¦¨ÁZ
¨º§Ú­Ì¬O¤£¬O­n¥ý§â­n¦Ò¸Õªº¬ì¥Ø­q¦n
¤~¤è ...
Min µoªí©ó 2010-5-3 00:12


mysql>drop table EnAndCn;
¤p¶{ª©¥D:¤£¦n·N«ä.ÂØ­z¤U¤å
DROP TABLE ³¯­z¦¡µLªk³Q¥Î¨Ó§R°£¨t²Î¸ê®Æªí.
1.°²³]§Ú­Ì·Q­n±N¸ê®Æ®w DemoDb ¤¤ªº Customer¡BEnAndCn »P Alex µ¥¤T­Ó¸ê®Æªí§R°£¡A½Ð°õ¦æ¤U¦C©R¥O¡G
USE DemoDb;
DROP TABLE Customer, EnAndCn, Alex ;
2. °²³]§Ú­Ì·Q­n±N¤U¦Cªº¸ê®Æªí§R°£¡G
¸ê®Æ®w DemoDb ¤¤¡Aµ²ºc´y­z¦WºÙ¬° EnAndCn ªº¸ê®Æªí DemoTable¡C
¸ê®Æ®w TestDb ¤¤¡Aµ²ºc´y­z¦WºÙ¬° Alex ªº¸ê®Æªí TestTable¡C
¸ê®Æ®w MyDb ¤¤¡A¥Ñ SQL Server ¹w³]µ¹¤©¤§µ²ºc´y­z¦WºÙªº¸ê®Æªí MyTabletest¡C
±ý§R°£¤W­z¸ê®Æªí¡A½Ð°õ¦æ¤U¦C©R¥O±Ô­z¡G
DROP TABLE DemoDb.EnAndCn.DemoTable,
             TestDb. Alex.TestTable,
             MyDb.dbo.MyTabletest;
ÁÂÁÂ!

TOP

is null¦³®É³£¥Î¤£¤F
­n¥Î='' ~"~

TOP

        ÀR«ä¦Û¦b : ºw¤ô¦¨ªe¡C²É¦Ì¦¨ÅÚ¡A¤Å»´¤vÆF¡A¤Å¥Hµ½¤p¦Ó¤£¬°¡C
ªð¦^¦Cªí ¤W¤@¥DÃD