When replication is used, adding an
same ordering of the rows on the slave and the master. This occurs because the order in which the
rows are numbered depends on the specific storage engine used for the table and the order in which
the rows were inserted. If it is important to have the same order on the master and slave, the rows
must be ordered before assigning an
AUTO_INCREMENT
but with an
t1
CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY)
SELECT * FROM t1 ORDER BY col1, col2;
This assumes that the table
This set of statements will also produce a new table
AUTO_INCREMENT
CREATE TABLE t2 LIKE t1;
ALTER TABLE t2 ADD id INT AUTO_INCREMENT PRIMARY KEY;
INSERT INTO t2 SELECT * FROM t1 ORDER BY col1, col2;
Regardless of the method used to create and populate the copy having the
the final step is to drop the original table and then rename the copy:
DROP t1;
ALTER TABLE t2 RENAME t1;
13.1.5.
ALTER VIEW
ALTER
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = {
[SQL SECURITY { DEFINER | INVOKER }]
VIEW
view_name
AS
select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
This statement changes the definition of a view, which must exist. The syntax is similar to that for
CREATE VIEW
"CREATE VIEW
for the view, and some privilege for each column referred to in the
5.0.52,
ALTER VIEW
This statement was added in MySQL 5.0.1. The
as of MySQL 5.0.16 to specify the security context to be used when checking access privileges at view
invocation time. For details, see
13.1.6.
CREATE DATABASE
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS]
[create_specification] ...
create_specification:
[DEFAULT] CHARACTER SET [=]
| [DEFAULT] COLLATE [=]
CREATE DATABASE
[576]
CREATE
MySQL 5.0.2.
An error occurs if the database exists and you did not specify
ALTER VIEW
AUTO_INCREMENT
column to the table t1, the following statements produce a new table
column:
AUTO_INCREMENT
has columns
t1
column:
Important
To guarantee the same ordering on both master and slave, all columns of
must be referenced in the
Syntax
user
| CURRENT_USER }]
[(column_list)]
and the effect is the same as for
Syntax". This statement requires the
is permitted only to the original definer or users with the
Section 13.1.12,
Syntax
charset_name
collation_name
creates a database with the given name. To use this statement, you need the
privilege for the database.
Syntax
column to a table might not produce the
number. Assuming that you want to add an
AUTO_INCREMENT
and col2.
col1
identical to t1, with the addition of an
t2
clause.
ORDER BY
CREATE OR REPLACE
CREATE VIEW
and
DEFINER
"CREATE VIEW
db_name
is a synonym for
CREATE SCHEMA
1020
AUTO_INCREMENT
VIEW. See
Section 13.1.12,
[577]
and
DROP
statement. As of MySQL
SELECT
SUPER
clauses may be used
SQL SECURITY
Syntax".
CREATE DATABASE
IF NOT
EXISTS.
identical to
t2
t1
column,
[577]
privileges
[578]
privilege.
as of
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers