Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

วิธีเขียน Comment ใน MySQL (3 รูปแบบ)

MySQL รองรับการเขียน Comment 3 รูปแบบ:

1. Single-line ด้วย #

mysql> CREATE TABLE CommentDemo (
    -> id INT  # Id is an integer type
    -> );

2. Single-line ด้วย -- (ต้องมี space หลัง --)

mysql> CREATE TABLE CommentDemo2 (
    -> id INT  -- id is an integer type
    -> );

3. Multi-line ด้วย /* */ (เหมือน C/C++)

mysql> CREATE TABLE CommentDemo3 (
    -> /* id is an integer type
    ->    คำอธิบายหลายบรรทัด */
    -> id INT
    -> );
รูปแบบใช้ได้กับหมายเหตุ
# ...บรรทัดเดียวMySQL เฉพาะ
-- ...บรรทัดเดียวมาตรฐาน SQL (ต้องมี space)
/* ... */หลายบรรทัดมาตรฐาน SQL
แนะนำ: ใช้ -- หรือ /* */ เพื่อความเข้ากันได้กับ Database อื่น และเครื่องมือ Migration