Hiển thị các bài đăng có nhãn MySQL. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn MySQL. Hiển thị tất cả bài đăng

Thứ Ba, 31 tháng 1, 2012

Foreign Key trong MySQL

Để tạo khóa ngoại trong MySQL


Create table Orders
(orderid int primary key,
ccode varchar(10) not null,
orderdate date,
foreign key(ccode) references customers(ccode))

Không phải sử dụng theo SQL chuẩn


Create table Orders
(orderid int primary key,
ccode varchar(10) not null foreign key(ccode) references customers(ccode)
orderdate date,
)

Unicode trong MySQL

TRONG MySQL KHÔNG CẦN DÙNG KÝ TỰ N NHƯ TRONG SQL Server


Để thiết lập kiểu dữ liệu Unicode trong MySQL

CREATE TABLE `dgs` ( 
`id` INT( 5 ) NOT NULL , 
`name` VARCHAR( 255 ) NOT NULL , 
PRIMARY KEY ( `re` ) 
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Hoặc trong PHP

mysql_query("SET NAMES 'UTF8'");