1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(207) : error C2146: syntax error : missing ';' before identifier 'dbch_size' 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(207) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(207) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(208) : error C2146: syntax error : missing ';' before identifier 'dbch_devicetype' 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(208) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(209) : error C2146: syntax error : missing ';' before identifier 'dbch_reserved' 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(209) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(209) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\dbt.h(213) : error C2143: syntax error : missing ';' before '*'
뭐..이건 SVN help 를 통해서 찾은내용이고 웹에 떠도는 내용을 토대로 실제 백업과 복구를 해보았다.
svnadmin help 명령어를 사용하면 hotcopy 이외에 여러가지 명령어가 나오는데 그중에
dump 와 load 명령어를 사용하면 된다.
* dump - 특정 프로젝트를 백업하는 명령어 - $ svnadmin help dump ┌──────────────────────────────────────── │ dump: 사용법: svnadmin dump REPOS_PATH [-r LOWER[:UPPER]] [--incremental] │ 파일 시스템의 내용을 stdout 으로 포터블한 형식의 'dumpfile'로 적재하며, │ stderr로 피드백을 보냅니다. 리비젼 LOWER rev 부터 UPPER rev 까지 │ 적재합니다. 주어진 리비젼이 없다면, 모든 리비젼 트리를 적재합니다. │ --incremental 옵션을 사용한다면, 모든 내용이 아닌 이전 버젼과의 차이만 적재됩니다. │ 옵션: │ -r [--revision] arg : 리비젼 넘버 ARG ( 또는 X:Y 범위 )를 지정합니다 │ --incremental : incremental 적재를 합니다. │ --deltas : 적재된 결과물에 deltas를 사용합니다 │ -q [--quiet] : stderr 에 대한 진행사항이 (오류에 한해서) 없습니다 └────────────────────────────────────────
* load - 특정 프로젝트를 복구 하는 명령어 - $ svnadmin help load ┌──────────────────────────────────────── │ load: 사용법: svnadmin load REPOS_PATH │ stdin 으로 'dumpfile' 형식의 스트림을 읽어들여, 새로운 리비젼을 │ 저장소의 파일시스템으로 커밋합니다. 이전에 저장소가 │ 비어있었다면, 기본적으로 그것의 UUID 가 스트림에 지정된 │ 한가지로 변경될것입니다. 진행 피드백은 stdout 으로 전송됩니다. │ 옵션: │ -q [--quiet] : stderr 에 대한 진행사항이 (오류에 한해서) 없습니다 │ --ignore-uuid : 스트림에 어떤 repos UUID가 발견되어도 무시합니다 │ --force-uuid : 만약 있다면, repos UUID 를 스트림에서 발견된 것에 설정합니다, │ --use-pre-commit-hook : 리비전을 새로이 커밋하기 전 post-commit 훅을 호출합니다. │ --use-post-commit-hook : 리비전을 새로이 커밋한 뒤 post-commit 훅을 호출합니다. │ --parent-dir arg : 저장소의 지정된 디렉토리에 로드합니다 └────────────────────────────────────────
1. 사용자 추가 [root][ use mysql ] > GRANT ALL ON <DATABASE 명 혹은 테이블명> TO <사용자명>@<호스트명> IDENTIFIED BY '비밀번호'; 2. 사용자 로긴이 안될수 있다. 비밀번호의 해슁때문인데 이땐 암호를 한번더 변경시켜준다. > update user set password=password('<password>') where user='<user>'; 3. 데이터베이스 권한 설정 > insert into db values ('localhost', '<DATABASE 명>', '<사용자명>', 'y', 'y' ...); 4. 시스템에 적용 > flush privileges;
이 주소에서 "Windows installer with the basic win32 binaries" 버전을 다운로드 받습니다. 여러가지 버전이 많은데 다른 버전을 받으면 왠지 세팅할것이 매우 많을 것 같다는 생각이 들거든요. SVN 서버를 전문적으로 관리 하실분들은 다른 버전을 다운 받으셔도 무방합니다.
2. 다운 받은 파일을 "다음" 버튼이 사라지고 "마침" 버튼이 나올때까지 눌러서 설치합니다. (대부분의 MS Windows 응용프로그램은 이렇게 설치하죠. -_-)
3. 설치를 했으면 Repository 를 세팅해야합니다. Repository 는 영문을 그대로 번역하자면 저장소 라고 하는데 앞으로 사용할 프로젝트를 넣어두는 폴더 라고 생각하시면 됩니다. 만드는 방법은 간단합니다. 그냥 폴더를 하나 만드시면 끝납니다. -0- d:\>mkdir svn_repo
4. 서버를 실행시켜야 합니다. 서버를 실행시키는 방법도 매우~!!! 간단합니다. svnserve -d -r [저장소경로] 라고 입력만 하면 SVN 서버가 가동됩니다. d:\>svnserve -d -r d:/svn_repo |:\>svnserve -d -r d:/svn_repo 도스창(cmd.exe)에서 실행시켰다면 그 상태 그대로가 서버가 동작하는 상태입니다. 창을 꺼(Ctrl+C)버리면 서버는 종료됩니다.
↑↑↑↑↑↑↑↑↑↑↑↑↑ <== 서버 설치 끝!
초간단 서버 설치는 끝났습니다. 그럼 다음은 초간단 프로젝트 생성입니다.
이렇게 설치를 하고나면 아무짝에도 쓸모가 없습니다. 자신의 프로젝트를 직접 세팅해야 비로소 제대로된 SVN 서버세팅이라고 할 수 있습니다.
1. 설치해둔 Repository 경로로 이동한 후 다음 명령어로 프로젝트를 초기화 합니다. d:\>cd svn_repo d:\svn_repo> d:\svn_repo>svnadmin create --fs-type fsfs svntestprj 위 명령어는 svntestprj 라는 이름으로 파일시스템 타입이 DB 를 생성하는 명령어 입니다. 만일 버클리 타입의 DB를 생성하려면 다음과 같이 생성해야합니다. d:\svn_repo>svnadmin create --fs-type bdb svntestprj 버클리? 파일시스템 DB? 둘의 차이점은 도움말을 참고하세요.
↑↑↑↑↑↑↑↑↑↑↑↑↑ <== 프로젝트 생성 끝!
마지막으로 프로젝트 세팅까지 끝냈으면 서버 관리를 좀더 편하게 하는 툴을 사용하는것을 권장 합니다. 매번 PC를 켜서 로그인 후에 커맨드창을 열어서 서버 실행 명령어를 치는것은 여간 귀찮은 작업이 아닙니다.
ALTER [IGNORE] TABLE tbl_name
alter_specification [, alter_specification] ...
alter_specification:
ADD [COLUMN] column_definition [FIRST | AFTER col_name ]
| ADD [COLUMN] (column_definition,...)
| ADD INDEX [index_name] [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
PRIMARY KEY [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
UNIQUE [index_name] [index_type] (index_col_name,...)
| ADD [FULLTEXT|SPATIAL] [index_name] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
FOREIGN KEY [index_name] (index_col_name,...)
[reference_definition]
| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
| CHANGE [COLUMN] old_col_name column_definition
[FIRST|AFTER col_name]
| MODIFY [COLUMN] column_definition [FIRST | AFTER col_name]
| DROP [COLUMN] col_name
| DROP PRIMARY KEY
| DROP INDEX index_name
| DROP FOREIGN KEY fk_symbol
| DISABLE KEYS
| ENABLE KEYS
| RENAME [TO] new_tbl_name
| ORDER BY col_name
| CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]
| [DEFAULT] CHARACTER SET charset_name [COLLATE collation_name]
| DISCARD TABLESPACE
| IMPORT TABLESPACE
| table_options
ALTER TABLE allows you to change the structure of an existing table. For example, you can add or delete columns, create or destroy indexes, change the type of existing columns, or rename columns or the table itself. You can also change the comment for the table and type of the table.
The syntax for many of the allowable alterations is similar to clauses of the CREATE TABLE statement. See section 14.2.5 CREATE TABLE Syntax.
If you use ALTER TABLE to change a column specification but DESCRIBE tbl_name indicates that your column was not changed, it is possible that MySQL ignored your modification for one of the reasons described in section 14.2.5.1 Silent Column Specification Changes. For example, if you try to change a VARCHAR column to CHAR, MySQL will still use VARCHAR if the table contains other variable-length columns.
ALTER TABLE works by making a temporary copy of the original table. The alteration is performed on the copy, then the original table is deleted and the new one is renamed. While ALTER TABLE is executing, the original table is readable by other clients. Updates and writes to the table are stalled until the new table is ready, then are automatically redirected to the new table without any failed updates.
Note that if you use any other option to ALTER TABLE than RENAME, MySQL always creates a temporary table, even if the data wouldn't strictly need to be copied (such as when you change the name of a column). We plan to fix this in the future, but because ALTER TABLE is not a statement that is normally used frequently, this isn't high on our TODO list. For MyISAM tables, you can speed up the index re-creation operation (which is the slowest part of the alteration process) by setting the myisam_sort_buffer_size system variable to a high value.
To use ALTER TABLE, you need ALTER, INSERT, and CREATE privileges for the table.
IGNORE is a MySQL extension to standard SQL. It controls how ALTER TABLE works if there are duplicates on unique keys in the new table. If IGNORE isn't specified, the copy is aborted and rolled back if duplicate-key errors occur. If IGNORE is specified, then for rows with duplicates on a unique key, only the first row is used. The others are deleted.
You can issue multiple ADD, ALTER, DROP, and CHANGE clauses in a single ALTER TABLE statement. This is a MySQL extension to standard SQL, which allows only one of each clause per ALTER TABLE statement. For example, to drop multiple columns in a single statement:
mysql> ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;
CHANGE col_name, DROP col_name, and DROP INDEX are MySQL extensions to standard SQL.
MODIFY is an Oracle extension to ALTER TABLE.
The word COLUMN is purely optional and can be omitted.
If you use ALTER TABLE tbl_name RENAME TO new_tbl_name without any other options, MySQL simply renames any files that correspond to the table tbl_name. There is no need to create a temporary table. (You can also use the RENAME TABLE statement to rename tables. See section 14.2.9 RENAME TABLE Syntax.)
column_definition clauses use the same syntax for ADD and CHANGE as for CREATE TABLE. Note that this syntax includes the column name, not just the column type. See section 14.2.5 CREATE TABLE Syntax.
You can rename a column using a CHANGE old_col_name column_definition clause. To do so, specify the old and new column names and the type that the column currently has. For example, to rename an INTEGER column from a to b, you can do this:
mysql> ALTER TABLE t1 CHANGE a b INTEGER;
If you want to change a column's type but not the name, CHANGE syntax still requires an old and new column name, even if they are the same. For example:
mysql> ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;
However, as of MySQL 3.22.16a, you can also use MODIFY to change a column's type without renaming it:
mysql> ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
If you use CHANGE or MODIFY to shorten a column for which an index exists on part of the column (for example, if you have an index on the first 10 characters of a VARCHAR column), you cannot make the column shorter than the number of characters that are indexed.
When you change a column type using CHANGE or MODIFY, MySQL tries to convert existing column values to the new type as well as possible.
In MySQL 3.22 or later, you can use FIRST or AFTER col_name to add a column at a specific position within a table row. The default is to add the column last. From MySQL 4.0.1 on, you can also use FIRST and AFTER in CHANGE or MODIFY operations.
ALTER COLUMN specifies a new default value for a column or removes the old default value. If the old default is removed and the column can be NULL, the new default is NULL. If the column cannot be NULL, MySQL assigns a default value, as described in section 14.2.5 CREATE TABLE Syntax.
DROP INDEX removes an index. This is a MySQL extension to standard SQL. See section 14.2.7 DROP INDEX Syntax.
If columns are dropped from a table, the columns are also removed from any index of which they are a part. If all columns that make up an index are dropped, the index is dropped as well.
If a table contains only one column, the column cannot be dropped. If what you intend is to remove the table, use DROP TABLE instead.
DROP PRIMARY KEY drops the primary index. (Prior to MySQL 4.1.2, if no primary index exists, DROP PRIMARY KEY drops the first UNIQUE index in the table. MySQL marks the first UNIQUE key as the PRIMARY KEY if no PRIMARY KEY was specified explicitly.) If you add a UNIQUE INDEX or PRIMARY KEY to a table, it is stored before any non-unique index so that MySQL can detect duplicate keys as early as possible.
ORDER BY allows you to create the new table with the rows in a specific order. Note that the table will not remain in this order after inserts and deletes. This option is mainly useful when you know that you are mostly going to query the rows in a certain order; by using this option after big changes to the table, you might be able to get higher performance. In some cases, it might make sorting easier for MySQL if the table is in order by the column that you want to order it by later.
If you use ALTER TABLE on a MyISAM table, all non-unique indexes are created in a separate batch (as for REPAIR TABLE). This should make ALTER TABLE much faster when you have many indexes. As of MySQL 4.0, this feature can be activated explicitly. ALTER TABLE ... DISABLE KEYS tells MySQL to stop updating non-unique indexes for a MyISAM table. ALTER TABLE ... ENABLE KEYS then should be used to re-create missing indexes. MySQL does this with a special algorithm that is much faster than inserting keys one by one, so disabling keys before performing bulk insert operations should give a considerable speedup. Using ALTER TABLE ... DISABLE KEYS will require the INDEX privilege in addition to the privileges mentioned earlier.
The FOREIGN KEY and REFERENCES clauses are supported by the InnoDB storage engine, which implements ADD [CONSTRAINT [symbol]] FOREIGN KEY (...) REFERENCES ... (...). See section 16.7.4 FOREIGN KEY Constraints. For other storage engines, the clauses are parsed but ignored. The CHECK clause is parsed but ignored by all storage engines. See section 14.2.5 CREATE TABLE Syntax. The reason for accepting but ignoring syntax clauses is for compatibility, to make it easier to port code from other SQL servers, and to run applications that create tables with references. See section 1.8.5 MySQL Differences from Standard SQL.
Starting from MySQL 4.0.13, InnoDB supports the use of ALTER TABLE to drop foreign keys:
ALTER TABLE yourtablename DROP FOREIGN KEY fk_symbol;
ALTER TABLE ignores the DATA DIRECTORY and INDEX DIRECTORY table options.
From MySQL 4.1.2 on, if you want to change all character columns (CHAR, VARCHAR, TEXT) to a new character set, use a statement like this:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;
This is useful, for example, after upgrading from MySQL 4.0.x to 4.1.x. See section 11.10 Upgrading Character Sets from MySQL 4.0. Warning: The preceding operation will convert column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
The reason this works is that there is no conversion when you convert to or from BLOB columns. To change only the default character set for a table, use this statement:
ALTER TABLE tbl_name DEFAULT CHARACTER SET charset_name;
The word DEFAULT is optional. The default character set is the character set that is used if you don't specify the character set for a new column you add to a table (for example, with ALTER TABLE ... ADD column). Warning: From MySQL 4.1.2 and up, ALTER TABLE ... DEFAULT CHARACTER SET and ALTER TABLE ... CHARACTER SET are equivalent and change only the default table character set. In MySQL 4.1 releases before 4.1.2, ALTER TABLE ... DEFAULT CHARACTER SET changes the default character set, but ALTER TABLE ... CHARACTER SET (without DEFAULT) changes the default character set and also converts all columns to the new character set.
For an InnoDB table that is created with its own tablespace in an `.ibd' file, that file can be discarded and imported. To discard the `.ibd' file, use this statement:
ALTER TABLE tbl_name DISCARD TABLESPACE;
This deletes the current `.ibd' file, so be sure that you have a backup first. Attempting to access the table while the tablespace file is discarded results in an error. To import the backup `.ibd' file back into the table, copy it into the database directory, then issue this statement:
With the mysql_info() C API function, you can find out how many records were copied, and (when IGNORE is used) how many records were deleted due to duplication of unique key values. See section 21.2.3.30 mysql_info().
Here are some examples that show uses of ALTER TABLE. Begin with a table t1 that is created as shown here:
mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
To rename the table from t1 to t2:
mysql> ALTER TABLE t1 RENAME t2;
To change column a from INTEGER to TINYINT NOT NULL (leaving the name the same), and to change column b from CHAR(10) to CHAR(20) as well as renaming it from b to c:
mysql> ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
To add a new TIMESTAMP column named d:
mysql> ALTER TABLE t2 ADD d TIMESTAMP;
To add indexes on column d and on column a:
mysql> ALTER TABLE t2 ADD INDEX (d), ADD INDEX (a);
To remove column c:
mysql> ALTER TABLE t2 DROP COLUMN c;
To add a new AUTO_INCREMENT integer column named c:
mysql> ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
-> ADD PRIMARY KEY (c);
Note that we indexed c (as a PRIMARY KEY), because AUTO_INCREMENT columns must be indexed, and also that we declare c as NOT NULL, because primary key columns cannot be NULL.
When you add an AUTO_INCREMENT column, column values are filled in with sequence numbers for you automatically. For MyISAM tables, you can set the first sequence number by executing SET INSERT_ID=value before ALTER TABLE or by using the AUTO_INCREMENT=value table option. See section 14.5.3.1 SET Syntax.
With MyISAM tables, if you don't change the AUTO_INCREMENT column, the sequence number will not be affected. If you drop an AUTO_INCREMENT column and then add another AUTO_INCREMENT column, the numbers are resequenced beginning with 1.
IF you want to change a SET or ENUM column you may not want to use the ALTER TABLE ... MODIFY syntax. It tries to keep the actual string values and not the integer representation of the values, even though they are stored as integers. For example, if you just want to make a change in spelling of the values in your enum column or your set column, consider doing it like this: ALTER TABLE table ADD new_column ...; UPDATE table SET new_column = old_column + 0; ALTER TABLE table DROP old_column;
You can use Alter Table to optimise a table without locking out selects (only writes), by altering a column to be the same as it's current definition. This is better than using repair table which obtains a read/write lock.
E.g. mysql> describe Temp_Table;
+-------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+-------+ | ID | int(10) unsigned | YES | | NULL | | +-------+------------------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> alter table Temp_Table change column ID ID int unsigned;
This will cause mysql to re-create the table and thus remove any deleted space.
This is useful for 24/7 databases where you don't want to completely lock a table.
Posted by Radhakrishnan Ayyappanaicker on April 13 2004 2:41am
while adding primary key constraint on null allowable integer column, mysql assigns default value 0 iff one NULL value exists on that column else alter table will fail with error "Duplicate entry '0' for key 1"
User Comments
IF you want to change a SET or ENUM column you may
not want to use the ALTER TABLE ... MODIFY
syntax.
It tries to keep the actual string values and not
the integer representation of the values, even
though they are stored as integers.
For example, if you just want to make a change in
spelling of the values in your enum column or your
set column, consider doing it like this:
ALTER TABLE table ADD new_column ...;
UPDATE table SET new_column = old_column + 0;
ALTER TABLE table DROP old_column;
You can use Alter Table to optimise a table without locking out selects (only writes), by altering a column to be the same as it's current definition. This is better than using repair table which obtains a read/write lock.
1 row in set (0.00 sec)E.g.
mysql> describe Temp_Table;
mysql> alter table Temp_Table change column ID ID int unsigned;
This will cause mysql to re-create the table and thus remove any deleted space.
This is useful for 24/7 databases where you don't want to completely lock a table.
while adding primary key constraint on null allowable integer column, mysql assigns default value 0 iff one NULL value exists on that column else alter table will fail with error "Duplicate entry '0' for key 1"
If you use ALTER TABLE to add a new column and set a DEFAULT value for the new column, then this value will be assigned to all the existing records.
So if you have a table with 100 records in, then use the following statement:
ALTER TABLE me.my_table
ADD COLUMN new_column INT NOT NULL DEFAULT 0;
then all the existing records will now have the value '0' in this new column 'new_column'.
In other words, you do not need to run the following UPDATE statement:
UPDATE me.my_table SET new_column = 0;
Hope this helps someone!
Mark Sweeting
http://www.sweeting.org/mark/
Add your own comment.