Professional Documents
Culture Documents
1.Chun b
MySQL c hai phin chinh l MySQL Enterprise v MSQL Community
Server. Trong phn thc hnh ny ta chn MySQL Community Server
phin bn 5.0.45 v MySQL GUI Tools phin bn 5.0.12 ti
http://dev.mysql.com/downloads.
sau:
-u
root
Server Host:
Port:
33S
Username:
Password:
Details >>
OK
Clear
Cancel
Trang: 2
E dt
View
S c iv c i
Tools
Window
MySQL Enterprise
Help
Irrfomwtiun
Service Control
Startup Variables
A 3 User Administration
Server Connections
Health
Server Logs
Replication Status
Backup
^4
Restore
information_schema
mysql
test
OK
Cancel
Trang: 3
* MySQL Administrator
F ie
Edit
View
Took
S e iv o f In fo rm a tio n
'.
E H T3E
Window
MySQL Enterprise
Help
Schem a Tables
Schema Indices
Views
S toted procedures
Service Control
J Startup Variables
3
csld_congly
AI tables of the csd_congty schema
User Administration
Server Connections
Table Name
'
Engine
D ata len .
Index len...
update time
I Data Len
OB
I Index Len
V j Heallh
Server Logs
Replication Status
Backup
L ,^ j Restore
!^ /
Catalogs
information_schema
Jroysq!
lest
[ito
~Create T
Edt Table
Maintenance
WHERE
Trang: 4
><
Stored Connection:
Server Host:
Port:
330S
Username:
Password:
Default Schema:
Details
OK
Clear
Cancel
jn .
Cc nt chc nng
Dng thc thi hoc: dng cc lnh truy vn. Nt Execute
dng thc thi cc lnh truy vn hin thi trong vng son
tho. Nt Stop dng chm dt cc lnh thc thi nu vic
thc thi xy ra qu lu m cha cho ra kt qu.
TINYINT
SMALLINT
MEDIUMINT
INT
BIGINT
Ki ch
thc
(Bytes)
Gi tr nh nht
(Du / Khng du)
Gi tr ln nht
(Du / khng du)
-128
127
255
-32,768
32,767
65,535
-8,308,608
0,300,607
16,777,215
-2,147,483,648
2,147,483,647
4,294,967,295
9,223,372,036,854,775
9,223,372,036,854,77
5, 807
Trang: 8
18,446,744,073,709,5
51,615
trong
SQL m
rng
cng
tng ong vi
Ki ch
thc
(Bytes)
DATE
TIME
DATETIME
TIMESTAMP
YEAR
nink khng c xc nh
nm l hai ch s theo quy
nm t 70 - 99 uc
nm t 00 - 69 c
MySQL t
thnh mt
Gi tr zero
DATETIME
'0000-00-00
00:00:00'
DATE
'0000-00-00'
TIMESTAMP
'0000-00-00
00:00:00'
YEAR
o
o
o
o
o
TIME
nm
gi
gi
mt
0000
phin
bn
(Y2K).
k. Kiu chui
Cc kiu chui gm CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT,
ENUM.
Kiu CHAR v VARCHAR
Kiu CHAR v VARCHAR tng t nhau nhng khc nhau cch cc
gi tr ca chng c lu tr v khi phc.
Kiu CHAR v VARCHAR c khai bo vi di nh r s
ti a cc k t m mt gi tr c th c. v d, CHAR (30)
th gi tr l mt chui c th cha ti a 30 k t.
Vi kiu CHAT di c th c gi tr t 0 n 255. Khi mt
chui gi tr kiu CHAR c lu, cc k t trng c ghp
vo cui chui c chiu di nh chiu di nh. Khi mt
chui gi tr CHAR c khi phc, cc k t trng cui
chui s b xa.
Cc gi tr kiu VARCHAR l cc chui c di thay i.
di c th c gi tr t 0 n 65535. Khc vi kiu CHAR, cc
gi tr kiu VARCHAR c lu vi di thc.
Nu cc chui gi tr c di ln hn di c xc
nh th chui s b ct bt cc k t cui c c
di nh xc nh. Bng 1.4 minh ha s khc nhau ca kiu
CHAR v VARCHAR.
Chui gi
tr
C H A R (4)
VARCHAR(4)
f f
'ab'
'ab
'
1a b 1
'abcd'
'abcd'
'abed'
'abcdefg'
'abed'
'abed'
6.To
cha cc gi tr
Kiu ENUM
Kiu ENUM cha cc gi
CSDL
trong MySQL
lchui
tr l cc chui
nhphn
c lit
chui
ktrc.
Administrator
contac*_dat abase
csd_congy
Edit Schema
nc*maion_schefna
Drop Schema
mynewdatabase
mysql
phpmyadrmn
Itest
hjandafabase
luandripaSOa
F2
Ctrl* Del
Ctrl+C
Ctri+N
Ctri+T
Ctrl+V
Ctrl*p
F5
rr
Please enter a name for the new schema.
Schema name:
chuyenba^
OK
Trang: 13
Edit
View
Tools
G e iv e r In fo r m a tio n
SeiviceControl
SttupVariables
UserAdministration
SeiverConnections
-*Health
seiverLogs
0 ReplicationStatus
Backup
QjJ Restore
'
^, Catalogs
7.To Bng
Window
MySQL Enterprise
Help
SchemaTables SchemaIndicesIViewsjjiloredprocedures
^
chuyenbdy
3 Alltablesofthechuyeroayschema
TableName
Engine
Rows
C trl+ T
C reate N e w V iew
C trl+ V
ctrl+p
Refresh
F5
Trang: 14
Table Options
Column Name
Indices
Foreign Keys
D atabase:
chuyenbay
Comment:
Advanced Options
Datatype
Default Value
Comment
Column Details
Index Settings
Index Columns
Index Name:
Index Kind:
INDEX
Index Type:
DEFAULT
(Use Dtagn'Diop
+ -
+vng
tab gm 3 phn :
Columns and Indices: s dng tab n to v hiu chinh thng tin
ch s v ct ca bng. Ta cng to quan h KHA NGOI trong tab ny.
loi
d liu,
- To bng:
+ Ta g tn bng vo Table Name
- To field cho bng:
+ Ta g tn field trong ct Column Name,
kiu d
liu ca field trong ct Datatype. Nu
field bt buc phi c gi
tr th check vo ct NOT NULL,.... v d ta to cc field
cho bng
chuyenbay trong CSDL chuyenbay nh hnh bn di.
Trang: 15
Database: chuyenbay
Columns and Indices
Column Name
Table Options
Advanced Options
Datatype
MaCB
Comment:
CHAR(5)
hull f t T
Flags
BINARY
Default Value
<i GaOi
BINARY
<i GaDen
BINARY
INTEGER
UNSIGNED
DoDai
GioDi
<i GioDen
0
ChiPhl
Indices
ASCII
ZEROFILL
[
1 UNSIGNED
ZEROFILL
TIME
T|ME
2 , INTEGER
Comment
UNIC
nnn
" 3 PRIMARY
Index Name:
PRIMARY
IndexColumns
MaCB
Index Kind:
PRIMARY
Index Type:
BTREE
+ -
Trang: 16
Database:
Table Options
Column Name
0
MaCB
GaDi
Datatype
mull
S)?'3
CHAR(5)
Flags
Default Value
BINARY
ASCII
BINARY
E2S
BINARY
Eaa
UNSIGNED
2 , INTEGER
GioDi
TIME
GioDen
TIME
cnn
ChiPhi
2 , INTEGER
Indices
Name:
UNSIGNED
Comment
UNIC
<i GaDen
< DoDai
Advanced Options
ZEROFILL
ZEROFILL
real
Datatype:
CHAR (5)
Default Value:
Flags:
BINARY
ASCII
UNICODE
Column Charset:
Utf8
Column Collate:
U tf8 _ g en eral_ ci
I I Primary Key
Not Null
EH Auto Increment
Comment
Apply Changes
Discard Changes
Trang: 17
T able Name,
chuyenbay
Database.
Datatype
GaDen
< DoDai
GioDen
Q ChiPhi
Name:
me10
Default Value
BINARY
b in a r y
can
BINARY
EM
UNSIGNED
ASCII
ZEROFILL
K'jili
TIME
C2U3
UNSIGNED
Comment
UNIC
TIME
2 , INTEGER
Foreign Keys
Flags
J b INTEGER
GioDi
Indices
hull
I CHAR (5)
<i GaDi
Comment.
Column Name
MaCB
chuyenbay
ZEROFILL
Column Details
MaCB
Column Options
Datatype:
CHAR (5)
Default Value:
Flags:
n BINARY
ASCII
UNICODE
Column Charset:
J Primary Key
ulf8
Column Collate:
Not Null
n Auto Increment
Comment:
Apply Changes
Discard Changes
Trang: 18
tg Server Information
tielp
1
Schema Tables
Stored procedures
P / Service Control
Startup Variables
chuyenbay
All tables of the chuyenbay schema
User Administration
Server Connections
f j Health
Server Logs
Replication Status
Table Name
fr
Engine
chungnhan
chuyenbay
Rows
0
Data length
16 kB
Index length
16 kB
Update time
MylSAM
maybay
MylSAM
OB
1 kB
2008-10-03 09:36:08
OB
1 kB
nhanvien
MylSAM
OB
2008-10-03 09:36:08
1 kB
2008-10-03 09:36:08
Backup
Restoie
Catalogs
Num. of Tables:
Table Status
Schemata
[ZU
-I chuyenbay
collections
drupal57a
infofmation_schema
mysql
phpmyadmin
| R ow s:
Ol Data Len:
18 kB
11ndex Len
19 kB
Row Status
chungnhan
Detailed table sta:us information
General
Table Type:
Row format:
Auto Increment:
Create options:
InnoDB
Compact
Comment:
studymgdatabase
p) test
tuandatabase
Detads
Create Table
drt Table
Maintenance
efresh
tuandrupal6
Trang: 19
Table Options
Database: chuyenbay
Advanced Options
Storage Engine
Table Engine:
Supports transactions, row-level locking, and foreign keys
Character Set
Charset:
Utf8
The default character set that is used for the table. Starting from MySQL 4.1 you
can specify an individual character set for each column
Collation:
Utf8_general_ci
Apply Changes
Discard Changes
Close
Trang: 20
Database: chuyenbay
Table Options
Advanced Options
Datatype
mull
Sic0
Flags
Default Value
MaNV
CHAR(9)
BINARY
ASCII
MaMB
INTEGER
UNSIGNED
Comment
UNIC
ZEROFILL
Ref. Table:
On Delete:
No Action
On Update:
No Action
Column
Reference Column
Apply Changes
Discard Changes
Close
OK
iungnhan_nhanvien_fk
Cancel
Trang: 21
Indices
chungnhan_nhanvien_f
On Delete:
Restrict
On Update:
Restrict
Foreign Keys
-lei. Table:
Column
chungnhan
chuyenbay
mavbay
Column Details
Foreign Key Settings
Key Name:
chungnhan_nhanvien_f
On Delete:
Restrict
On Update:
Ref. Table:
nhanvien
Column
Reference Column
MaNV
MaNV
Restrict
Apply Changes
Discard Changes
Close
(5<]
Are you sure you want to execute the following SQL command to apply the changes to the table?
ALTER TABLE chuyenbay.'chungnhan' DROP FOREIGN KEY 'FK_chungnhan_1
ADD CONSTRAINT 'chungnhan nhanvien fk'FOREIGN KEY'chungnhan nhanvien fk'
('MaNV')
REFERENCES 'nhanvien' ('MaNV')
ON DELETE RESTRICT
ON UPDATE RESTRICT
, ROW FORMAT = DYNAMIC;
Execute
Cancel
+ Chn Execute
Trang: 22
chun g n ha n
Columns a nd Indices
chuyenbay
Column N am e
M aN V
MaM B
Indices
D atabase:
D atatype
> C H A R (9)
huI i
IN TEG ER
Foreign Keys
m c
Flags
Default V a lu e
B IN A R Y
U N S IG N E D
ASCII
Comment
UNIC
2 E R 0 F IL L
Column Details
Foreign Key Settings
Key Name:
| ch u n g n h a n _ n h a n v ie n _ f|
On D elete:
R estrict
On U pdate
R estricf
A pply Changes
R efere n ce Column
M aN V
d is c a rd Changes
Close
Trang: 23
Views
Stored procedures
c h u ye n b a y
All tables of the chuyenbay schema
Engine
Rows
chungnhan
InnoDB
chuyenbay
My ISAM
maybay
InnoDB
0
0
0
fF1 nhanvier
Update time
16 kB
16 kB
OB
1 kB
16 kB
OB
16 kB
Edit Table
2008-10-03 09:36:08
Table Name
-n
Schema Indices
Create Table
Rows:
I Data Len:
48 kB j I Index Len:
17 kB
Drop Table
Refresh
nhanvi
Detailed table status information
General
Table Type:
InnoD B
Row format:
C om pact
Auto Increment:
Create options:
Comment:
Trang: 24
+ Chn Edit
+ Ri nhp liu trong vng Resultset 1
Trang: 25