Nội phân bài viết Trong hướng dẫn này, bạn sẽ tìm hiểu cách thực hiện nhiều truy vấn SQL bằng Node.js và MySQL. Để thực hiện nhiều câu lệnh SQL, bạn cần Bật tùy chọn Bultiplestatements. Theo mặc định, nhiều câu lệnh bị vô hiệu hóa vì lý do bảo mật. Tham khảo: //www.technicalkeeda.com/nodejs-gutorials/nodejs-mysql-multiple-statement-queriesVideo học lập trình mỗi ngài
7 - Tải mô -đun MySQL để kết nối với cơ sở dữ liệu.mysql module to connect to database.
8.
9 trong khi có được kết nối, trong ví dụ này, chúng tôi sẽ tìm nạp các bản ghi từ các bảng "TRN_employee" và "trn_person".
0 - Đóng kết nối cơ sở dữ liệu.var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
đầu ra
Tôi đang sử dụng
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
1 + var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
2 + var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
3 + var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
4.Tôi đã nhận được 4 xóa và chỉ muốn 1 yêu cầu cơ sở dữ liệu, vì vậy tôi đã kết nối các lệnh xóa với ";" ... nhưng nó luôn thất bại.
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
Nó ném lỗi này:
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
Nhưng nếu tôi dán SQL này vào phpmyadmin thì nó luôn thành công ...
Nếu tôi viết nó trong một truy vấn duy nhất, nó cũng thành công.
connection.query["DELETE FROM user_tables WHERE name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
}];
}];
}];
Cảm ơn vì sự giúp đỡ!
13.2.2 & NBSP; Xóa tuyên bố
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 là một câu lệnh DML loại bỏ các hàng khỏi bảng.Một câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 có thể bắt đầu với mệnh đề var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
7 để xác định các biểu thức bảng phổ biến có thể truy cập trong var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5. Xem phần & nbsp; 13.2.15, với [biểu thức bảng phổ biến].Cú pháp bảng đơn
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
Câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 xóa các hàng từ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
0 và trả về số lượng hàng bị xóa. Để kiểm tra số lượng hàng đã bị xóa, hãy gọi hàm Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
1 được mô tả trong Phần & NBSP; 12.16, các chức năng thông tin của Hồi giáo.Mệnh đề chính
Các điều kiện trong mệnh đề
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2 tùy chọn xác định các hàng nào sẽ xóa. Không có mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2, tất cả các hàng bị xóa.
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
4 là một biểu thức đánh giá đúng cho mỗi hàng sẽ bị xóa. Nó được chỉ định như được mô tả trong Phần & NBSP; 13.2.10, Câu lệnh Chọn.Nếu mệnh đề
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
5 được chỉ định, các hàng sẽ bị xóa theo thứ tự được chỉ định. Điều khoản Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
6 đặt giới hạn về số lượng hàng có thể bị xóa. Các mệnh đề này áp dụng cho các xóa bảng đơn, nhưng không phải là xóa nhiều bảng.Cú pháp nhiều bàn
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
Đặc quyền
Bạn cần đặc quyền
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 trên bảng để xóa các hàng khỏi nó. Bạn chỉ cần đặc quyền Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
8 cho bất kỳ cột nào chỉ được đọc, chẳng hạn như các cột được đặt tên trong mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2.Màn biểu diễn
Khi bạn không cần biết số lượng hàng bị xóa, câu lệnh
connection.query["DELETE FROM user_tables WHERE name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
}];
}];
}];
0 là một cách nhanh hơn để trống một bảng so với câu lệnh var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 không có mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2. Không giống như var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5, connection.query["DELETE FROM user_tables WHERE name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
}];
}];
}];
0 không thể được sử dụng trong giao dịch hoặc nếu bạn có khóa trên bàn. Xem Phần & NBSP; 13.1.37, Tuyên bố bảng cắt ngắn và Phần & NBSP; 13.3.6, Bảng khóa và mở khóa Bảng câu lệnh.Tốc độ xóa các hoạt động cũng có thể bị ảnh hưởng bởi các yếu tố được thảo luận trong Phần & NBSP; 8.2.5.3, Tối ưu hóa các câu lệnh xóa.
Để đảm bảo rằng một câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 đã cho không mất quá nhiều thời gian, mệnh đề connection.query["DELETE FROM user_tables WHERE name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
connection.query["DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase'", function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
}];
}];
}];
6 dành riêng cho MySQL cho var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 chỉ định số lượng hàng tối đa bị xóa. Nếu số lượng hàng để xóa lớn hơn giới hạn, hãy lặp lại câu lệnh var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 cho đến khi số lượng hàng bị ảnh hưởng nhỏ hơn giá trị Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
6.Subqueries
Bạn không thể xóa khỏi bảng và chọn từ cùng một bảng trong một truy vấn con.
Hỗ trợ bảng phân vùng
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 hỗ trợ lựa chọn phân vùng rõ ràng bằng mệnh đề DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
1, lấy một danh sách các tên được phân tách bằng dấu phẩy của một hoặc nhiều phân vùng hoặc phân vùng [hoặc cả hai] để chọn các hàng bị bỏ. Các phân vùng không bao gồm trong danh sách bị bỏ qua. Đưa ra một bảng được phân vùng DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
2 với một phân vùng có tên DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
3, thực thi câu lệnh DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
4 có tác dụng tương tự trên bảng như thực thi DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
5; Trong cả hai trường hợp, tất cả các hàng trong phân vùng DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
3 đều bị loại bỏ.
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
1 có thể được sử dụng cùng với điều kiện Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2, trong trường hợp đó điều kiện chỉ được kiểm tra trên các hàng trong các phân vùng được liệt kê. Ví dụ: DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
9 chỉ xóa các hàng từ phân vùng DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
3 mà điều kiện DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
1 là đúng; Hàng trong bất kỳ phân vùng nào khác không được kiểm tra và do đó không bị ảnh hưởng bởi var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5.Điều khoản
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION [partition_name [, partition_name] ...]]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
1 cũng có thể được sử dụng trong các câu lệnh var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 nhiều bảng. Bạn có thể sử dụng tối đa một tùy chọn như vậy cho mỗi bảng có tên trong tùy chọn DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
5.Để biết thêm thông tin và ví dụ, xem Phần & NBSP; 24.5, Lựa chọn phân vùng.
Cột tự động
Nếu bạn xóa hàng chứa giá trị tối đa cho cột
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
6, giá trị không được sử dụng lại cho bảng DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7 hoặc DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8. Nếu bạn xóa tất cả các hàng trong bảng với xóa từ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
0 [không có mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2] ở chế độ DELETE FROM somelog WHERE user = 'jcole'
ORDER BY timestamp_column LIMIT 1;
1, chuỗi bắt đầu lại cho tất cả các công cụ lưu trữ ngoại trừ DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8 và DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7. Có một số ngoại lệ đối với hành vi này đối với các bảng DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8, như đã thảo luận trong Phần & NBSP; 15.6.1.6, Xử lý Auto_increment trong Innodb.DELETE
FROM Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
0
[without a Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2 clause] in
DELETE FROM somelog WHERE user = 'jcole'
ORDER BY timestamp_column LIMIT 1;
1 mode, the sequence starts over for all storage engines except DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8 and DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7. There are some exceptions to this behavior for DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8 tables, as discussed in Section 15.6.1.6, “AUTO_INCREMENT Handling in
InnoDB”. Đối với các bảng
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7, bạn có thể chỉ định cột thứ cấp DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
6 trong phím nhiều cột. Trong trường hợp này, việc tái sử dụng các giá trị bị xóa khỏi đầu chuỗi xảy ra ngay cả đối với các bảng DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7. Xem Phần & NBSP; 3.6.9, Sử dụng Auto_increment.Sửa đổi
Tuyên bố
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 hỗ trợ các công cụ sửa đổi sau:Nếu bạn chỉ định công cụ sửa đổi
9, máy chủ sẽ trì hoãn việc thực thiDELETE FROM somelog WHERE user = 'jcole' ORDER BY timestamp_column LIMIT 1;
5 cho đến khi không có máy khách nào khác đọc từ bảng. Điều này chỉ ảnh hưởng đến các công cụ lưu trữ chỉ sử dụng khóa cấp bảng [chẳng hạn nhưvar sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';"; sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';"; sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';"; sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';"; connection.query[sql_string, function[err, rows, fields] { if [err] throw err; res.send['true']; }];
7,DELETE [LOW_PRIORITY] [QUICK] [IGNORE] tbl_name[.*] [, tbl_name[.*]] ... FROM table_references [WHERE where_condition] DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name[.*] [, tbl_name[.*]] ... USING table_references [WHERE where_condition]
2 vàINSERT INTO t_copy SELECT * FROM t WHERE ... ;
3].INSERT INTO t_copy SELECT * FROM t WHERE ... ;
Đối với các bảng
7, nếu bạn sử dụng công cụ sửa đổiDELETE [LOW_PRIORITY] [QUICK] [IGNORE] tbl_name[.*] [, tbl_name[.*]] ... FROM table_references [WHERE where_condition] DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name[.*] [, tbl_name[.*]] ... USING table_references [WHERE where_condition]
5, công cụ lưu trữ không hợp nhất các chỉ số chỉ số trong quá trình xóa, điều này có thể tăng tốc một số loại hoạt động xóa.INSERT INTO t_copy SELECT * FROM t WHERE ... ;
Công cụ sửa đổi
6 khiến MYSQL bỏ qua các lỗi không thể tin được trong quá trình xóa các hàng. [Lỗi gặp phải trong giai đoạn phân tích cú pháp được xử lý theo cách thông thường.] Các lỗi bị bỏ qua do sử dụngINSERT INTO t_copy SELECT * FROM t WHERE ... ;
6 được trả về dưới dạng cảnh báo. Để biết thêm thông tin, hãy xem ảnh hưởng của việc bỏ qua đối với việc thực thi tuyên bố.INSERT INTO t_copy SELECT * FROM t WHERE ... ;
Thứ tự xóa
Nếu câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 bao gồm mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
5, các hàng sẽ bị xóa theo thứ tự được chỉ định bởi mệnh đề. Điều này hữu ích chủ yếu kết hợp với Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
6. Ví dụ: câu lệnh sau đây tìm thấy các hàng khớp với mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2, sắp xếp chúng bằng RENAME TABLE t TO t_old, t_copy TO t;
2 và xóa cái đầu tiên [lâu đời nhất]:DELETE FROM somelog WHERE user = 'jcole'
ORDER BY timestamp_column LIMIT 1;
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
5 cũng giúp xóa các hàng theo thứ tự cần thiết để tránh vi phạm toàn vẹn tham chiếu.Bàn innodb
Nếu bạn đang xóa nhiều hàng từ một bảng lớn, bạn có thể vượt quá kích thước bảng khóa cho bảng
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8. Để tránh vấn đề này, hoặc đơn giản là để giảm thiểu thời gian mà bảng vẫn bị khóa, chiến lược sau [hoàn toàn không sử dụng var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5] có thể hữu ích:Chọn các hàng không bị xóa vào một bảng trống có cùng cấu trúc với bảng gốc:not to be deleted into an empty table that has the same structure as the original table:
INSERT INTO t_copy SELECT * FROM t WHERE ... ;
Sử dụng
6 để di chuyển một cách nguyên tử trên bảng gốc và đổi tên bản sao thành tên gốc:RENAME TABLE t TO t_old, t_copy TO t;
RENAME TABLE t TO t_old, t_copy TO t;
Thả bảng ban đầu:
0- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Không có phiên nào khác có thể truy cập các bảng liên quan trong khi
RENAME TABLE t TO t_old, t_copy TO t;
6 thực thi, vì vậy hoạt động đổi tên không phải chịu các vấn đề đồng thời. Xem Phần & NBSP; 13.1.36, Tuyên bố Đổi tên Bảng.Bàn myisam
Trong các bảng
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
7, các hàng bị xóa được duy trì trong danh sách được liên kết và các hoạt động RENAME TABLE t TO t_old, t_copy TO t;
9 tiếp theo tái sử dụng các vị trí hàng cũ. Để đòi lại không gian không sử dụng và giảm kích thước tệp, hãy sử dụng câu lệnh 00 hoặc tiện ích Myisamchk để tổ chức lại các bảng.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
00 dễ sử dụng hơn, nhưng Myisamchk nhanh hơn. Xem phần & nbsp; 13.7.3.4, Tối ưu hóa bảng câu lệnh bảng, và phần & nbsp; 4.6.4, Myisamchk-tiện ích bảo trì bảng myisam.myisamchk utility to reorganize tables.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
00 is easier to use, but myisamchk is faster. See Section 13.7.3.4, “OPTIMIZE TABLE Statement”, and Section 4.6.4, “myisamchk — MyISAM Table-Maintenance Utility”.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Công cụ sửa đổi
INSERT INTO t_copy SELECT * FROM t WHERE ... ;
5 ảnh hưởng đến việc liệu lá chỉ mục có được hợp nhất cho các hoạt động xóa hay không. 03 hữu ích nhất cho các ứng dụng trong đó các giá trị chỉ mục cho các hàng bị xóa được thay thế bằng các giá trị chỉ mục tương tự từ các hàng được chèn vào sau. Trong trường hợp này, các lỗ hổng còn lại bởi các giá trị bị xóa được sử dụng lại.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
03 không hữu ích khi các giá trị bị xóa dẫn đến các khối chỉ mục bị thiếu hụt một loạt các giá trị chỉ mục mà các chèn mới lại xảy ra. Trong trường hợp này, việc sử dụng
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
INSERT INTO t_copy SELECT * FROM t WHERE ... ;
5 có thể dẫn đến không gian lãng phí trong chỉ số vẫn chưa được báo cáo. Dưới đây là một ví dụ về một kịch bản như vậy:Tạo một bảng chứa cột
6 được lập chỉ mục.DELETE [LOW_PRIORITY] [QUICK] [IGNORE] tbl_name[.*] [, tbl_name[.*]] ... FROM table_references [WHERE where_condition] DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name[.*] [, tbl_name[.*]] ... USING table_references [WHERE where_condition]
Chèn nhiều hàng vào bàn. Mỗi phần chèn kết quả trong một giá trị chỉ mục được thêm vào cấp cao của chỉ mục.
Xóa một khối các hàng ở đầu thấp của phạm vi cột bằng cách sử dụng
03.- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Trong kịch bản này, các khối chỉ mục được liên kết với các giá trị chỉ mục đã bị xóa trở nên thiếu thốn nhưng không được hợp nhất với các khối chỉ mục khác do sử dụng
INSERT INTO t_copy SELECT * FROM t WHERE ... ;
5. Chúng vẫn bị thiếu khi chèn mới xảy ra, bởi vì các hàng mới không có giá trị chỉ mục trong phạm vi bị xóa. Hơn nữa, chúng vẫn được lấp đầy ngay cả khi sau đó bạn sử dụng var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 mà không cần INSERT INTO t_copy SELECT * FROM t WHERE ... ;
5, trừ khi một số giá trị chỉ số bị xóa xảy ra trong các khối chỉ mục trong hoặc liền kề với các khối bị thiếu. Để đòi lại không gian chỉ mục không sử dụng trong những trường hợp này, hãy sử dụng 00.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Nếu bạn định xóa nhiều hàng khỏi bảng, có thể sử dụng
03 nhanh hơn, sau đó là
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
00. Điều này xây dựng lại chỉ mục thay vì thực hiện nhiều hoạt động hợp nhất khối chỉ mục.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Xóa đa bàn
Bạn có thể chỉ định nhiều bảng trong câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 để xóa các hàng khỏi một hoặc nhiều bảng tùy thuộc vào điều kiện trong mệnh đề Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
2. Bạn không thể sử dụng 16 hoặc
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
6 trong var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 nhiều bảng. Điều khoản 19 liệt kê các bảng liên quan đến tham gia, như được mô tả trong Phần & NBSP; 13.2.10.2, Điều khoản tham gia.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Đối với cú pháp nhiều bảng đầu tiên, chỉ các hàng khớp từ các bảng được liệt kê trước mệnh đề
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
5 bị xóa. Đối với cú pháp nhiều bảng thứ hai, chỉ khớp các hàng từ các bảng được liệt kê trong mệnh đề DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
5 [trước mệnh đề 22] bị xóa. Hiệu ứng là bạn có thể xóa các hàng từ nhiều bảng cùng một lúc và có thêm các bảng chỉ được sử dụng để tìm kiếm:
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
1
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Hoặc:
2
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Các câu lệnh này sử dụng cả ba bảng khi tìm kiếm các hàng để xóa, nhưng chỉ xóa các hàng khớp chỉ từ các bảng
23 và
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
24.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Các ví dụ trước sử dụng
25, nhưng các câu lệnh
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 nhiều bảng có thể sử dụng các loại tham gia khác được phép trong các câu lệnh Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
8, chẳng hạn như 28. Ví dụ: để xóa các hàng tồn tại trong
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
23 không phù hợp trong
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
24, sử dụng
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
28:
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
3
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Cú pháp cho phép
32 sau mỗi
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';DELETE FR' at line 1
0 để tương thích với quyền truy cập.Access. Nếu bạn sử dụng câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 nhiều bảng liên quan đến các bảng DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8 có các ràng buộc chính của nước ngoài, trình tối ưu hóa MySQL có thể xử lý các bảng theo thứ tự khác với mối quan hệ cha mẹ/trẻ em của họ. Trong trường hợp này, tuyên bố thất bại và quay trở lại. Thay vào đó, bạn nên xóa khỏi một bảng và dựa vào các khả năng 36 mà
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition]
8 cung cấp để khiến các bảng khác được sửa đổi phù hợp.Ghi chú
Nếu bạn khai báo bí danh cho một bảng, bạn phải sử dụng bí danh khi đề cập đến bảng:
4
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Bí danh bảng trong một bảng nhiều bảng
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 chỉ nên được khai báo trong phần 19 của câu lệnh.Ở những nơi khác, tài liệu tham khảo bí danh được cho phép nhưng không phải là khai báo bí danh.
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Chính xác:
5
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Không đúng:
6
- [ { employee_id: 2, first_name: 'Dinesh', last_name: 'Patil' } ]
- [ { person_id: 1, first_name: 'Yashwant', last_name: 'Chavan', age: 10 } ]
Bí danh bảng cũng được hỗ trợ cho các câu lệnh
var sql_string = "DELETE FROM user_tables WHERE name = 'Testbase';";
sql_string += "DELETE FROM user_tables_structure WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_rules WHERE parent_table_name = 'Testbase';";
sql_string += "DELETE FROM user_tables_columns WHERE parent_table_name = 'Testbase';";
connection.query[sql_string, function[err, rows, fields] {
if [err] throw err;
res.send['true'];
}];
5 bảng bắt đầu bằng MySQL 8.0.16.[Lỗi #89410, lỗi #27455809]