¹ØÓÚmysqlµÄ¾Û¼¯Ë÷Òý
·Ò룺
InnoDB±í»á°üº¬Ò»¸ö¾Û¼¯Ë÷Òý£¨Êý¾Ý±íµÄÎïÀí´æ´¢Ë³ÐòºÍ±íµÄÂß¼´æ´¢Ë³ÐòÒ»Ö£©
Ò»°ãÊÇ°´ÕÕÏÂÃæµÄ¹æÔòÀ´É趨¾Û¼¯Ë÷ÒýµÄ£º
1£¬¼ÙÈç±í°üº¬PRIMARY KEY£¬InnoDBʹÓÃËü×÷Ϊ¾Û¼¯Ë÷Òý
2£¬¼ÙÈç±íûÓж¨ÒåPRIMARY KEY£¬InnoDB½«µÚÒ»¸öÖ»°üº¬NOT NULLÊôÐÔÁеÄUNIQUE index×÷ΪÖ÷¼ü²¢ÇÒ½«ËüÉèÖÃΪ¾Û¼¯Ë÷Òý
3£¬Ç°Á½Õ߶¼²»Âú×ãµÄʱºò£¬mysql¾ÍÔö¼ÓÒ»¸öÒþ²ØµÄautocreament
Every InnoDB
table has a special index called
the clustered index
where the data for
the rows is stored:
If you define a PRIMARY KEY
on your
table, InnoDB
uses it as the clustered
index.
If you do not define a PRIMARY KEY
for
your table, MySQL picks the first UNIQUE
index that has only NOT NULL
columns as
the primary key and InnoDB
uses it as the
clustered index.
If the table has no PRIMARY KEY
or
suitable UNIQUE
index,
InnoDB
internally generates a hidden
clustered index on a synthetic column containing row ID
values. The rows are ordered by the ID that
InnoDB
assigns to the rows in such a
table. The row ID is a 6-byte field that increases
monotonically as new rows are inserted. Thus, the rows
ordered by the row ID are physically in insertion order.
Accessing a row through the clustered index is fast because the
row data is on the same page where the index search leads. If a
table is large, the clustered index architecture often saves a
disk I/O operation when compared to storage organizations that
store row data using a different page from the index record.
(For example, MyISAM
uses one file for data
rows and another for index records.)
In InnoDB
, the records in nonclustered
indexes (also called secondary indexes) contain the primary ke
Ïà¹ØÎĵµ£º
Ò»¹²ÓÐÈý¸öÀࣺWriteFile ; ReadFile ; InsertDB ;
//WriteFile.java
//ÓÃÓÚ½«ÐÅϢдÈëÎı¾Îļþ
package org.mb.insertfromfile;
import java.io.*;
public class WriteFile{
private int count = 0 ;
public int getCount() {
return count;
}
public void setCount(int count) {
this.cou ......
ÔÚÉè¼Æ¹ØϵÊý¾Ý¿âʱÊÇÒª×ñÊØÒ»¶¨µÄ¹æÔòµÄ¡£ÓÈÆäÊÇÊý¾Ý¿âÉè¼Æ·¶Ê½ÏÖ¼òµ¥½éÉÜ1NF£¨µÚÒ»·¶Ê½£©£¬2NF£¨µÚ¶þ·¶Ê½£©£¬3NF£¨µÚÈý·¶Ê½£©ºÍBCNF£¬ÁíÓеÚËÄ·¶Ê½ºÍµÚÎ巶ʽÁôµ½ÒÔºóÔÙ½éÉÜ¡£ÔÚÄãÉè¼ÆÊý¾Ý¿â֮ʱ£¬ÈôÄÜ·ûºÏÕ⼸¸ö·¶Ê½£¬Äã¾ÍÊÇÊý¾Ý¿âÉè¼ÆµÄ¸ßÊÖ¡£
µÚÒ»·¶Ê½£¨1NF£©£ºÔÚ¹ØϵģʽRÖеÄÿһ¸ö¾ßÌå¹ØϵrÖУ¬Èç¹ûÿ¸öÊôÐÔÖµ¶¼Ê ......
¼ÙÉèmysql °²×°ÔÚc:ÅÌ£¬mysqlÊý¾Ý¿âµÄÓû§ÃûÊÇroot£¬ÃÜÂëÊÇ123456£¬Êý¾Ý¿âÃûÊÇtestdb£¬ÔÚd:Å̸ùĿ¼ÏÂÃæ´æ·Å±¸·ÝÊý¾Ý¿â£¬±¸·ÝÊý¾Ý¿âÃû×ÖΪbackup20070713.sql(20070713.sqlΪ±¸·ÝÈÕÆÚ)
±¸·ÝÊý¾Ý¿â£º
mysqldump -uroot -p123456 testdb>d:/backup20070713.sql
»Ö¸´Êý¾Ý¿â£º
ɾ³ýÔÓÐÊý¾Ý¿â£¬½¨Á¢Êý¾Ý¿â£¬°Ñ±¸·ÝÊý¾Ý ......
START TRANSACTION, COMMITºÍROLLBACKÓï·¨
START TRANSACTION | BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET AUTOCOMMIT = {0 | 1}
START
TRANSACTION»òBEGINÓï¾ä¿ÉÒÔ¿ªÊ¼Ò»ÏîеÄÊÂÎñ¡£COMMIT¿ÉÒÔÌá½»µ±Ç°ÊÂÎñ£¬ÊDZä¸ü³ÉΪÓÀ¾Ã±ä¸ü¡£ROLLBACK ......
MySQL¿ÉÒÔΪ²»Í¬µÄÓû§·ÖÅäÑϸñµÄ¡¢¸´ÔÓµÄȨÏÞ¡£ÕâЩ²Ù×÷´ó¶à¶¼¿ÉÒÔÓÃSQLÖ¸ÁîGrant£¨·ÖÅäȨÏÞ£©ºÍRevoke£¨»ØÊÕȨÏÞ£©À´ÊµÏÖ¡£ Grant¿ÉÒÔ°ÑÖ¸¶¨µÄȨÏÞ·ÖÅä¸øÌض¨µÄÓû§£¬Èç¹ûÕâ¸öÓû§²»´æÔÚ£¬Ôò»á´´½¨Ò»¸öÓû§¡£
Grant ³£Óøñʽ:
grant ȨÏÞ1,ȨÏÞ2,…ȨÏÞn on Êý¾Ý¿âÃû³Æ.±íÃû³Æ to Óû§Ãû@Óû§µØÖ· ide ......