Mysql
 sql >> Baza danych >  >> RDS >> Mysql

Składnia bazy danych SQL ALTER – wymienione przez DBMS

Ten artykuł zawiera SQL ALTER DATABASE składnia, zaimplementowana przez różne systemy zarządzania bazami danych (DBMS). Składnia jest podana dokładnie tak, jak każdy dostawca podał ją na swojej stronie internetowej. Kliknij odpowiedni link, aby wyświetlić więcej szczegółów na temat składni konkretnego dostawcy.

Omówione DBMS to MySQL, SQL Server, PostgreSQL i Oracle Database.

MySQL

Z podręcznika MySQL 5.7 Reference:

ALTER {DATABASE | SCHEMA} [db_name]
    alter_specification ...
ALTER {DATABASE | SCHEMA} db_name
    UPGRADE DATA DIRECTORY NAME

alter_specification:
    [DEFAULT] CHARACTER SET [=] charset_name
  | [DEFAULT] COLLATE [=] collation_name

Serwer SQL

Z dokumentacji Transact-SQL:

ALTER DATABASE { database_name  | CURRENT }
{
    MODIFY NAME = new_database_name 
  | COLLATE collation_name
  | <file_and_filegroup_options>
  | <set_database_options>
}
[;]

<file_and_filegroup_options >::=
  <add_or_modify_files>::=
  <filespec>::= 
  <add_or_modify_filegroups>::=
  <filegroup_updatability_option>::= 

<set_database_options>::=
  <optionspec>::= 
  <auto_option> ::= 
  <change_tracking_option> ::=
  <cursor_option> ::= 
  <database_mirroring_option> ::= 
  <date_correlation_optimization_option> ::=
  <db_encryption_option> ::=
  <db_state_option> ::=
  <db_update_option> ::=
  <db_user_access_option> ::=
  <external_access_option> ::=
  <FILESTREAM_options> ::=
  <HADR_options> ::=  
  <parameterization_option> ::=
  <recovery_option> ::= 
  <service_broker_option> ::=
  <snapshot_option> ::=
  <sql_option> ::= 
  <termination> ::=

PostgreSQL

Z podręcznika PostgreSQL 9.5:

ALTER DATABASE name [ [ WITH ] option [ ... ] ]

where option can be:

    ALLOW_CONNECTIONS allowconn
    CONNECTION LIMIT connlimit
    IS_TEMPLATE istemplate

ALTER DATABASE name RENAME TO new_name

ALTER DATABASE name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }

ALTER DATABASE name SET TABLESPACE new_tablespace

ALTER DATABASE name SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER DATABASE name SET configuration_parameter FROM CURRENT
ALTER DATABASE name RESET configuration_parameter
ALTER DATABASE name RESET ALL

Baza danych Oracle

Z dokumentacji online bazy danych Oracle 12c Wydanie 1 (12.1):

ALTER DATABASE [ database ]
  { startup_clauses
  | recovery_clauses
  | database_file_clauses
  | logfile_clauses
  | controlfile_clauses
  | standby_database_clauses
  | default_settings_clauses
  | instance_clauses
  | security_clause
  } ;

Poniżej przedstawiono szczegóły różnych klauzul.

klauzule_startupowe::=

{ MOUNT [ { STANDBY | CLONE } DATABASE ]
| OPEN
  { [ READ WRITE ]
      [ RESETLOGS | NORESETLOGS ]
        [ UPGRADE | DOWNGRADE ]
  | READ ONLY
  }
}

recovery_clauses ::=

{ general_recovery
| managed_standby_recovery
| BEGIN BACKUP
| END BACKUP
}

general_recovery ::=

RECOVER
[ AUTOMATIC ]
[ FROM 'location' ]
{ { full_database_recovery
  | partial_database_recovery
  | LOGFILE 'filename'
  }
  [ { TEST
    | ALLOW integer CORRUPTION
    | parallel_clause
    }...
  ]
| CONTINUE [ DEFAULT ]
| CANCEL
}

full_database_recovery ::=

[ STANDBY ] DATABASE
[ { UNTIL { CANCEL
          | TIME date
          | CHANGE integer
          | CONSISTENT
          }
  | USING BACKUP CONTROLFILE
  | SNAPSHOT TIME date
  }...
]

partial_database_recovery::=

{ TABLESPACE tablespace [, tablespace ]...
| DATAFILE { 'filename' | filenumber }
             [, 'filename' | filenumber ]...
}

parallel_clause::=

{ NOPARALLEL | PARALLEL [ integer ] }

managed_standby_recovery::=

RECOVER
{ MANAGED STANDBY DATABASE
    [ { USING ARCHIVED LOGFILE
      | DISCONNECT [FROM SESSION]
      | NODELAY
      | UNTIL CHANGE integer
      | UNTIL CONSISTENT
      | parallel_clause
      }...
    | FINISH
    | CANCEL
    ]
| TO LOGICAL STANDBY { db_name | KEEP IDENTITY }
}

database_file_clauses ::=

{ RENAME FILE  'filename' [, 'filename' ]...
   TO 'filename'
| create_datafile_clause
| alter_datafile_clause
| alter_tempfile_clause
| move_datafile_clause
}

create_datafile_clause::=

CREATE DATAFILE
   { 'filename' | filenumber }
     [, 'filename' | filenumber ]...
   }
   [ AS { file_specification
          [, file_specification ]...
        | NEW
        }
   ]

alter_datafile_clause::=

DATAFILE
   { 'filename' | filenumber }
     [, 'filename' | filenumber ]...
   }
   { ONLINE
   | OFFLINE [ FOR DROP ]
   | RESIZE size_clause
   | autoextend_clause
   | END BACKUP
   }

alter_tempfile_clause::=

TEMPFILE
   { 'filename' [, 'filename' ]...
   | filenumber [, filenumber ]...
   }
   { RESIZE size_clause
   | autoextend_clause
   | DROP [ INCLUDING DATAFILES ]
   | ONLINE
   | OFFLINE
   }

move_datafile_clause::=

MOVE DATAFILE ( 'filename' | 'ASM_filename' | file_number )
 [ TO ( 'filename' | 'ASM_filename' ) ]
 [ REUSE ] [ KEEP ]

ASM_filename::=

{ fully_qualified_file_name
| numeric_file_name
| incomplete_file_name
| alias_file_name
}

autoextend_clause ::=

AUTOEXTEND
   { OFF
   | ON [ NEXT size_clause ]
        [ maxsize_clause ]
   }

maxsize_clause::=

MAXSIZE { UNLIMITED | size_clause }

logfile_klauzule ::=

{ { ARCHIVELOG [ MANUAL ]
  | NOARCHIVELOG
  }
| [ NO ] FORCE LOGGING
| RENAME FILE 'filename' [, 'filename' ]...
    TO 'filename'
| CLEAR [ UNARCHIVED ]
    LOGFILE logfile_descriptor [, logfile_descriptor ]...
    [ UNRECOVERABLE DATAFILE ]
| add_logfile_clauses
| drop_logfile_clauses
| switch_logfile_clause
| supplemental_db_logging
}

add_logfile_clauses::=

ADD [ STANDBY ] LOGFILE
   { 
     { [ INSTANCE 'instance_name' ] | [ THREAD 'integer' ] }
     [ GROUP integer ] redo_log_file_spec
       [, [ GROUP integer ] redo_log_file_spec ]...
   | MEMBER 'filename' [ REUSE ] [, 'filename' [ REUSE ] ]...
        TO logfile_descriptor [, logfile_descriptor ]...
   }

drop_logfile_clauses::=

DROP [ STANDBY ] LOGFILE
   { logfile_descriptor
     [, logfile_descriptor ]...
   | MEMBER 'filename'
            [, 'filename' ]...
   }

switch_logfile_clause::=

SWITCH ALL LOGFILES TO BLOCKSIZE integer

supplemental_db_logging ::=

{ ADD | DROP } SUPPLEMENTAL LOG
{ DATA
| supplemental_id_key_clause
| supplemental_plsql_clause
}

supplemental_id_key_clause::=

DATA
( { ALL | PRIMARY KEY | UNIQUE | FOREIGN KEY }
    [, { ALL | PRIMARY KEY | UNIQUE | FOREIGN KEY } ]...
)
COLUMNS

supplemental_plsql_clause::=

DATA FOR PROCEDURAL REPLICATION

logfile_descriptor::=

{ GROUP integer
| ('filename' [, 'filename' ]...)
| 'filename'
}

controlfile_clauses ::=

CREATE { [ LOGICAL | PHYSICAL ] STANDBY | FAR SYNC INSTANCE }
  CONTROLFILE AS
  'filename' [ REUSE ]
| BACKUP CONTROLFILE TO
  { 'filename' [ REUSE ]
  | trace_file_clause
  }

klauzule_standby_database_clauses ::=

{ { activate_standby_db_clause
| maximize_standby_db_clause
| register_logfile_clause
| commit_switchover_clause
| start_standby_clause
| stop_standby_clause
| convert_database_clause
} [ parallel_clause ] }
|
{ switchover_clause | failover_clause }

activate_standby_db_clause::=

ACTIVATE
     [ PHYSICAL | LOGICAL ]
     STANDBY DATABASE
     [ FINISH APPLY ]

maximize_standby_db_clause::=

SET STANDBY DATABASE TO MAXIMIZE
{ PROTECTION | AVAILABILITY | PERFORMANCE }

register_logfile_clause::=

REGISTER [ OR REPLACE ]
  [ PHYSICAL | LOGICAL ]
LOGFILE [ file_specification  [, file_specification ]...
  [ FOR logminer_session_name ]

klauzula_switchover::=

SWITCHOVER TO target_db_name [ VERIFY | FORCE ]

failover_clause::=

FAILOVER TO target_db_name [ FORCE ]

commit_switchover_clause::=

{ PREPARE | COMMIT } TO SWITCHOVER
[ TO { { [ PHYSICAL | LOGICAL ] PRIMARY
     | [ PHYSICAL ] STANDBY
     } [ { WITH | WITHOUT } SESSION SHUTDOWN
         { WAIT | NOWAIT }
       ]
     | LOGICAL STANDBY
     }
| CANCEL
]

start_standby_clause::=

START LOGICAL STANDBY APPLY
[ IMMEDIATE ]
[ NODELAY ]
[ NEW PRIMARY dblink
| INITIAL [ scn_value ]
| { SKIP FAILED TRANSACTION | FINISH }
]

stop_standby_clause::=

{ STOP | ABORT } LOGICAL STANDBY APPLY

convert_database_clause::=

CONVERT TO ( PHYSICAL | SNAPSHOT ) STANDBY

default_settings_clauses::=

{ DEFAULT EDITION = edition_name
| SET DEFAULT { BIGFILE | SMALLFILE } TABLESPACE
| DEFAULT TABLESPACE tablespace
| DEFAULT TEMPORARY TABLESPACE { tablespace | tablespace_group_name }
| RENAME GLOBAL_NAME TO database.domain [.domain ]...
| ENABLE BLOCK CHANGE TRACKING [ USING FILE 'filename' [ REUSE ] ]
| DISABLE BLOCK CHANGE TRACKING
| [NO] FORCE FULL DATABASE CACHING
| flashback_mode_clause
| set_time_zone_clause
}

set_time_zone_clause::=

SET TIME_ZONE =
   '{ { + | - } hh : mi | time_zone_region }'

flashback_mode_clause ::=

FLASHBACK { ON | OFF }

instance_clauses::=

{ ENABLE | DISABLE } INSTANCE 'instance_name'

klauzula_zabezpieczeń ::=

GUARD { ALL | STANDBY | NONE }

Korzystanie z GUI

Większość DBMS umożliwia modyfikowanie baz danych za pomocą GUI. Może to być graficzny interfejs użytkownika dostarczany z produktem lub opracowany przez firmę zewnętrzną. Na przykład MySQL Workbench to narzędzie z graficznym interfejsem użytkownika, którego można używać z MySQL.


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Przedstawiamy ClusterControl 1.4.1 — wydanie ProxySQL

  2. MySQL — warunkowe ograniczenia klucza obcego

  3. Czy można zrobić klucz obcy MySQL w jednej z dwóch możliwych tabel?

  4. Jak zmienić nazwę przesłanego pliku przed zapisaniem go w katalogu?

  5. Czy w MySQL mogę skopiować jeden wiersz, aby wstawić go do tej samej tabeli?