mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
MS SQL: Support export
This commit is contained in:
@@ -654,10 +654,56 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
|||||||
return true; // ALTER USER is permanent
|
return true; // ALTER USER is permanent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_sql($table, $auto_increment, $style) {
|
||||||
|
global $driver;
|
||||||
|
if (is_view(table_status($table))) {
|
||||||
|
$view = view($table);
|
||||||
|
return "CREATE VIEW " . table($table) . " AS $view[select]";
|
||||||
|
}
|
||||||
|
$fields = array();
|
||||||
|
$primary = false;
|
||||||
|
foreach (fields($table) as $name => $field) {
|
||||||
|
$val = process_field($field, $field);
|
||||||
|
if ($val[6]) {
|
||||||
|
$primary = true;
|
||||||
|
}
|
||||||
|
$fields[] = implode("", $val);
|
||||||
|
}
|
||||||
|
foreach (indexes($table) as $name => $index) {
|
||||||
|
if (!$primary || $index["type"] != "PRIMARY") {
|
||||||
|
$columns = array();
|
||||||
|
foreach ($index["columns"] as $key => $val) {
|
||||||
|
$columns[] = idf_escape($val) . ($index["descs"][$key] ? " DESC" : "");
|
||||||
|
}
|
||||||
|
$name = idf_escape($name);
|
||||||
|
$fields[] = ($index["type"] == "INDEX" ? "INDEX $name" : "CONSTRAINT $name " . ($index["type"] == "UNIQUE" ? "UNIQUE" : "PRIMARY KEY")) . " (" . implode(", ", $columns) . ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (foreign_keys($table) as $foreign) {
|
||||||
|
$fields[] = ltrim(format_foreign_key($foreign));
|
||||||
|
}
|
||||||
|
foreach ($driver->checkConstraints($table) as $name => $check) {
|
||||||
|
$fields[] = "CONSTRAINT " . idf_escape($name) . " CHECK ($check)";
|
||||||
|
}
|
||||||
|
return "CREATE TABLE " . table($table) . " (\n\t" . implode(",\n\t", $fields) . "\n)";
|
||||||
|
}
|
||||||
|
|
||||||
|
function truncate_sql($table) {
|
||||||
|
return "TRUNCATE TABLE " . table($table);
|
||||||
|
}
|
||||||
|
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
return "USE " . idf_escape($database);
|
return "USE " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trigger_sql($table) {
|
||||||
|
$return = "";
|
||||||
|
foreach (triggers($table) as $name => $trigger) {
|
||||||
|
$return .= create_trigger(" ON " . table($table), trigger($name)) . ";";
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@@ -674,7 +720,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return preg_match('~^(check|comment|columns|database|drop_col|indexes|descidx|scheme|sql|table|trigger|view|view_trigger)$~', $feature); //! routine|
|
return preg_match('~^(check|comment|columns|database|drop_col|dump|indexes|descidx|scheme|sql|table|trigger|view|view_trigger)$~', $feature); //! routine|
|
||||||
}
|
}
|
||||||
|
|
||||||
function driver_config() {
|
function driver_config() {
|
||||||
|
@@ -126,7 +126,7 @@ SET foreign_key_checks = 0;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($is_sql) {
|
if ($is_sql) {
|
||||||
echo "-- " . $connection->result("SELECT NOW()") . "\n";
|
echo "-- " . gmdate("Y-m-d H:i:s e") . "\n";
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@@ -266,11 +266,11 @@ function process_length($length) {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function process_type($field, $collate = "COLLATE") {
|
function process_type($field, $collate = "COLLATE") {
|
||||||
global $unsigned;
|
global $unsigned, $jush;
|
||||||
return " $field[type]"
|
return " $field[type]"
|
||||||
. process_length($field["length"])
|
. process_length($field["length"])
|
||||||
. (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
. (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
||||||
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
|
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . ($jush == "mssql" ? $field["collation"] : q($field["collation"])) : "")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ SQLite: Support CHECK constraint
|
|||||||
SQLite: Add command Check tables
|
SQLite: Add command Check tables
|
||||||
SQLite: Display all rows of variable values
|
SQLite: Display all rows of variable values
|
||||||
SQLite: Remove support for SQLite version 2
|
SQLite: Remove support for SQLite version 2
|
||||||
|
MS SQL: Support export (bug #480)
|
||||||
MongoDB: Remove support for deprecated extension mongo
|
MongoDB: Remove support for deprecated extension mongo
|
||||||
|
|
||||||
Adminer-4.17.1 (released 2025-02-25):
|
Adminer-4.17.1 (released 2025-02-25):
|
||||||
|
Reference in New Issue
Block a user