Backup of SQL statement code in the current zone during the previous journey

Source: Internet
Author: User
Tags rtrim

Su-mysql-c "mysqld_safe-skip-name-resolve-open-files-limit = 4096 &"



Cd/usr/local/mysql/bin/
Mysqldump-u username-p password-databases Database Name>/backdata/ddd07-11-15. SQL

Mysqldump-databases zt>/data/ok1. SQL
Cd/usr/local/mysql/bin/
Mysql-uroot-pueoadir zt </backdata/kb. SQL
Mysqldump-uroot-pueoadir-databases zt>/backdata/back1210. SQL

Su-mysql-c "mysqld_safe-skip-name-resolve-open-files-limit = 4096 &"
Cd/usr/local/mysql/bin/
Mysql-uroot-pueoadir zt4 </backdata/new. SQL
Mysql-uroot-pueoadir zt </data/OK. SQL
UE processes the table imported from the negative Partition
Mysql FLServer </data/FLServer. SQL
Mysql GMTool </data/GMTool. SQL
Mysql LoginServer </data/LoginServer. SQL
Mysql roleChangeServer </data/roleChangeServer. SQL
Mysql roleregServer </data/roleregServer. SQL
Mysql unify00 </data/unify00. SQL



Mysql FLServer </data/FLServer. SQL
Mysql GMTool </data/GMTool. SQL
Mysql LoginServer </data/LoginServer. SQL
Mysql roleChangeServer </data/roleChangeServer. SQL
Mysql roleregServer </data/roleregServer. SQL
Mysql unify00 </data/unify00. SQL



Mysql FLServer </data/FLServer. SQL

Mysql zt </data/zt501. SQL
Mysql-uroot-pueoadir zt </backdata/kb. SQL
Query
Select * from zt4.CHARBASE where name in (select name from zt. zHARBASE)

Select * from CHARBASE limit 100.
Select UNIONID from CHARBASE lisubmit 100

Update
Update zt4.CHARBASE set name = CONCAT ('zone 1 ', rtrim (name) where name in (select name from zt. CHARBASE )'

Update CHARBASE set name = CONCAT (rtrim (name), '1q ')

Update CHARBASE set CHARID = CHARID + 10

Insert
Insert into zt. charbase select * FROM zt4.CHARBASE
Insert into game. user (name, pass) select name, pass from game2.user2

Import
Mysql-uroot-pueoadir zt </backdata/zt2q. SQL
Mysql-uroot-pueoadir zt </backdata/1q. SQL

Delete
Delete from charbase where round = 0 and level <80 and 'lastactivedate' <'2017-11-19 00:00:00 ′
Delete from charbase where round = 0 and onlinetime <4962 and 'lastactivedate' <'2017-11-19 00:00:00 ′



1. Delete players whose offline time exceeds five days and their online time is less than one hour!
Delete from zt. charbase where round = 0 and onlinetime <4962 and 'lastactivedate' <'2017-12-10 00:00:00 ′

Delete from zt. charbase where round = 0 and level <80 and 'lastactivedate' <'2017-11-22 00:00:00 ′
2. Remove duplicate gm charid numbers
SELECT max (CHARID) FROM 'charbase'

Update zt4.CHARBASE set CHARID = CHARID + 10000 where CHARID <100 LIMIT 50
Update zt4.CHARBASE set CHARID = CHARID + 20000 where CHARID in (select CHARID from zt. CHARBASE)

3. Remove duplicate characters
Update zt4.CHARBASE set name = CONCAT (rtrim (name), 'O') where name in (select name from zt. CHARBASE)

4. insert Table 2 data to Table 1

Insert into zt. charbase select * FROM zt4.CHARBASE

________________________________________________
Delete from zt4.CHARBASE where round = 0 and onlinetime <4962 and 'lastactivedate' <'2017-11-22 00:00:00 ′
Delete from zt4.CHARBASE where round = 0 and level <96 and 'lastactivedate' <'2017-12-10 00:00:00 ′
SELECT max (CHARID) FROM zt4.CHARBASE
Select * from zt4.CHARBASE limit 100.
Update zt4.CHARBASE set CHARID = CHARID + 10000 where CHARID in (select CHARID from zt. CHARBASE)
Update zt4.CHARBASE set name = CONCAT (rtrim (name), 'oo ') where name in (select name from zt. CHARBASE)

Insert into zt. charbase select * FROM zt4.CHARBASE
___________________________________________________________________________________
1. Delete players whose offline time exceeds five days and their online time is less than one hour!
Delete from zt. charbase where round = 0 and onlinetime <4962 and 'lastactivedate' <'2017-11-22 00:00:00 ′
Delete from zt4.CHARBASE where round = 0 and onlinetime <4962 and 'lastactivedate' <'2017-11-22 00:00:00 ′
Delete from zt. charbase where round = 0 and level <80 and 'lastactivedate' <'2017-11-22 00:00:00 ′
Delete from zt4.CHARBASE where round = 0 and level <80 and 'lastactivedate' <'2017-11-22 00:00:00 ′



2. Add 10000 before the CHARID processing duplicate IDs in the CHARBASE table

Update zt4.CHARBASE set zt4.CHARBASE. CHARID = zt4.CHARBASE. CHARID + 10000 where zt4.CHARBASE. CHARID in (select CHARID from zt. CHARBASE)
Repeated handling of CARTOONID and cartoonpet in the cartoonpet table
Update into set zt4.CARTOONPET. CARTOONID = zt4.CARTOONPET. CARTOONID + 10000 where zt4.CARTOONPET. CARTOONID in (SELECT zt4.CARTOONPET. CARTOONID from zt. CARTOONPET)





3. The SEPTID In the SEPT table is duplicated. Add 10000 before the duplicate ID.
Update zt4.SEPT, zt. SEPT set zt4.SEPT. SEPTID = zt4.SEPT. SEPTID + 10000 where zt4.SEPT. SEPTID in (select SEPTID from zt. SEPT)

4. Add 10000 before UNIONID processing in the UNIONMEMBER table

Update zt4.UNIONMEMBER set zt4.UNIONMEMBER. UNIONID = zt4.UNIONMEMBER. UNIONID + 10000 where zt4.UNIONMEMBER. UNIONID in (select UNIONID from zt. UNIONMEMBER)

5. synchronization between SEPTID and sept in the unionmember table
Update zt4.UNIONMEMBER, zt4.SEPT set zt4.UNIONMEMBER. SEPTID = zt4.SEPT. septid where zt4.UNIONMEMBER. NAME = zt4.SEPT. MASTER
6. synchronization between UNIONID and UNIONMEMBER in the UNION table
Update zt4.UNION, zt4.UNIONMEMBER set zt4.UNION. UNIONID = zt4.UNIONMEMBER. unionid where zt4.UNION. MASTER = zt4.UNIONMEMBER. NAME

7. synchronization between UNIONID and UNIONMEMBER In the SEPT table

Update zt4.SEPT, zt4.UNIONMEMBER set zt4.SEPT. UNIONID = zt4.UNIONMEMBER. unionid where zt4.SEPT. MASTER = zt4.UNIONMEMBER. NAME

8. The SEPTID processing in the CHARBASE table is consistent with that in the SEPT table.
Update zt4.CHARBASE, zt4.SEPT set zt4.CHARBASE. SEPTID = zt4.SEPT. septid where zt4.CHARBASE. NAME = zt4.SEPT. NAME
9. UNIONID processing in the CHARBASE table is consistent with that in the unionmember unionid table.
Update zt4.CHARBASE, zt4.UNIONMEMBER set zt4.CHARBASE. UNIONID = zt4.UNIONMEMBER. unionid where zt4.CHARBASE. NAME = zt4.UNIONMEMBER. NAME
10. The CHARID In the SEPT table is consistent with the CHARID in CHARBASE.
Update zt4.CHARBASE, zt4.SEPT set zt4.SEPT. CHARID = zt4.CHARBASE. charid where zt4.CHARBASE. NAME = zt4.SEPT. MASTER
The masterid in the cartoonpet table is consistent with the CHARID in CHARBASE.
Update zt4.CARTOONPET, zt4.CHARBASE set zt4.CARTOONPET. MASTERID = zt4.CHARBASE. CHARID where zt4.CHARBASE. NAME = zt4.CARTOONPET. MASTERNAME
12. The charid in the unionmember table is consistent with the CHARID in CHARBASE.
Update zt4.CHARBASE, zt4.UNIONMEMBER set zt4.UNIONMEMBER. CHARID = zt4.CHARBASE. charid where zt4.CHARBASE. NAME = zt4.UNIONMEMBER. NAME

13. The charid in the schoolmember table is consistent with the CHARID in CHARBASE.
Update zt4.CHARBASE, zt4.SCHOOLMEMBER set zt4.SCHOOLMEMBER. CHARID = zt4.CHARBASE. charid where zt4.CHARBASE. NAME = zt4.SCHOOLMEMBER. NAME



14. Processing of duplicate names in the CHARBASE table and the charbase name in the master database

Update zt4.CHARBASE set name = CONCAT (rtrim (name), 'oo ') where name in (select name from zt. CHARBASE)

15. Processing of duplicate names in the SEPT table and the main database SEPT NAME

Update zt4.SEPT set zt4.SEPT. NAME = CONCAT (rtrim (zt4.SEPT. NAME), 'oo ') where zt4.SEPT. NAME in (select NAME from zt. SEPT)

16. Processing of duplicate UNION names in the UNION table and master database
Update zt4.UNION set zt4.UNION. NAME = CONCAT (rtrim (zt4.UNION. NAME), 'oo ') where zt4.UNION. NAME in (select NAME from zt. UNION)





17. Processing of repeated SERIALID and SCHOOLMEMBER names in the SCHOOLMEMBER table
Update zt4.SCHOOLMEMBER set zt4.SCHOOLMEMBER. SERIALID = zt4.SCHOOLMEMBER. SERIALID + 10000 where zt4.SCHOOLMEMBER. SERIALID in (select SERIALID from zt. SCHOOLMEMBER)
18. The MASTER character names in the SEPT table are synchronized with those in CHAREBASE.
Update zt4.CHARBASE, zt4.SEPT set zt4.SEPT. MASTER = zt4.CHARBASE. name where zt4.CHARBASE. CHARID = zt4.SEPT. CHARID

19. Synchronize the NAME and CHARBASE character names in the SCHOOLMEMBER table
Update zt4.CHARBASE, zt4.SCHOOLMEMBER set zt4.SCHOOLMEMBER. NAME = zt4.CHARBASE. name where zt4.CHARBASE. CHARID = zt4.SCHOOLMEMBER. CHARID

20. The MASTER character names in the UNION table are synchronized with those in CHAREBASE.
Update zt4.CHARBASE, zt4.UNION set zt4.UNION. NAME = zt4.CHARBASE. name where zt4.CHARBASE. CHARID = zt4.UNION. CHARID
22. The mastername in the cartoonpet table is synchronized with the character name in CHAREBASE.
Update zt4.CHARBASE, zt4.CARTOONPET set zt4.CARTOONPET. MASTERNAME = zt4.CHARBASE. name where zt4.CHARBASE. CHARID = zt4.CARTOONPET. MASTERID

21. Merge the CHARBASE Database
Insert into zt. charbase select * FROM zt4.CHARBASE
22. Merge the SCHOOLMEMBER Database
Insert into zt. schoolmember select * FROM zt4.SCHOOLMEMBER
23. Merge the SEPT Database
Insert into zt. sept select * FROM zt4.SEPT

24. Merge the UNIONMEMBER Database

Insert into zt. unionmember select * FROM zt4.UNIONMEMBER

25. Merge UNION
Insert into zt. union select * FROM zt4.UNION

26. Merge CARTOONPET
Insert into zt. cartoonpet select * FROM zt4.CARTOONPET

26. Merge BALANCE
Insert into zt. balance select * FROM zt4.BALANCE

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.