MySQL是一種關(guān)系型數(shù)據(jù)庫管理系統(tǒng)。它能夠方便地管理大量的數(shù)據(jù),并提供豐富的可擴展性和安全性特性。在MySQL中,DML是指數(shù)據(jù)操作語言,通常用于查詢和操作數(shù)據(jù)。
USE database_name; //選擇數(shù)據(jù)庫 SELECT * FROM table_name; //查詢表的所有數(shù)據(jù) INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3); //插入新數(shù)據(jù) UPDATE table_name SET column1 = new_value1, column2 = new_value2 WHERE condition; //更新數(shù)據(jù) DELETE FROM table_name WHERE condition; //刪除數(shù)據(jù)
上述代碼均為DML語句,可以使用PHP等編程語言連接到MySQL數(shù)據(jù)庫進行執(zhí)行。例如:
connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows >0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "
"; } } else { echo "0 results"; } $conn->close(); ?>
通過以上PHP代碼,查詢MySQL中名為“MyGuests”的數(shù)據(jù)表中所有數(shù)據(jù)。