Project

General

Profile

How to clear database » History » Version 1

Ryan Supawarapong, 04/17/2026 01:35 AM

1 1 Ryan Supawarapong
# How to clear database
2
3
```
4
-- =============================================================================
5
-- Database Cleanup Script - Truncate All Tables
6
-- Generated: 2026-02-13
7
-- =============================================================================
8
-- This script will truncate all tables across multiple databases
9
-- WARNING: This will delete all data from the specified tables!
10
-- =============================================================================
11
12
-- Begin transaction to ensure atomicity
13
START TRANSACTION;
14
15
-- Disable foreign key checks to allow truncation without constraint errors
16
SET FOREIGN_KEY_CHECKS = 0;
17
18
-- =============================================================================
19
-- Database: banks
20
-- =============================================================================
21
USE banks;
22
23
TRUNCATE TABLE bill_payment_informations;
24
TRUNCATE TABLE biller_informations;
25
TRUNCATE TABLE bot_qrs;
26
TRUNCATE TABLE confirmations;
27
TRUNCATE TABLE initiations;
28
TRUNCATE TABLE inquirys;
29
TRUNCATE TABLE items;
30
TRUNCATE TABLE payer_informations;
31
TRUNCATE TABLE payment_verification_criterias;
32
TRUNCATE TABLE post_initiations;
33
TRUNCATE TABLE reversals;
34
TRUNCATE TABLE withholding_tax_information_items;
35
36
-- =============================================================================
37
-- Database: corporates
38
-- =============================================================================
39
USE corporates;
40
41
TRUNCATE TABLE addresses;
42
TRUNCATE TABLE answers;
43
TRUNCATE TABLE bank_transactions;
44
TRUNCATE TABLE banks;
45
TRUNCATE TABLE business_types;
46
TRUNCATE TABLE contacts;
47
TRUNCATE TABLE corporate_accounts;
48
TRUNCATE TABLE corporate_countries;
49
TRUNCATE TABLE corporate_financials;
50
TRUNCATE TABLE corporate_infos;
51
TRUNCATE TABLE corporate_tokens;
52
TRUNCATE TABLE corporate_types;
53
TRUNCATE TABLE corporates;
54
TRUNCATE TABLE country_source_incomes;
55
TRUNCATE TABLE customer_addresses;
56
TRUNCATE TABLE customer_bookbanks;
57
TRUNCATE TABLE customer_informations;
58
TRUNCATE TABLE customer_investment_occupations;
59
TRUNCATE TABLE customer_tokens;
60
TRUNCATE TABLE customers;
61
TRUNCATE TABLE documents;
62
TRUNCATE TABLE exchange_rates;
63
TRUNCATE TABLE fatca_knowledges;
64
TRUNCATE TABLE full_names;
65
TRUNCATE TABLE juristics;
66
TRUNCATE TABLE personals;
67
TRUNCATE TABLE source_of_incomes;
68
TRUNCATE TABLE suit_test_results;
69
TRUNCATE TABLE transactions;
70
71
-- =============================================================================
72
-- Database: customers
73
-- =============================================================================
74
USE customers;
75
76
TRUNCATE TABLE addresses;
77
TRUNCATE TABLE addresses_history;
78
TRUNCATE TABLE answers;
79
TRUNCATE TABLE answers_history;
80
TRUNCATE TABLE apipayments;
81
TRUNCATE TABLE apithb_details;
82
TRUNCATE TABLE apithb_headers;
83
TRUNCATE TABLE apithb_trailers;
84
TRUNCATE TABLE appman;
85
TRUNCATE TABLE appman_idcard;
86
TRUNCATE TABLE appman_liveness;
87
TRUNCATE TABLE appman_liveness_attributes;
88
TRUNCATE TABLE appman_recognition;
89
TRUNCATE TABLE b_payment_details;
90
TRUNCATE TABLE b_payment_headers;
91
TRUNCATE TABLE b_payment_trailers;
92
TRUNCATE TABLE balances;
93
TRUNCATE TABLE bank_transactions;
94
TRUNCATE TABLE bookbanks;
95
TRUNCATE TABLE bookbanks_history;
96
TRUNCATE TABLE bpm_report_details;
97
TRUNCATE TABLE bpm_report_headers;
98
TRUNCATE TABLE bpm_report_trailers;
99
TRUNCATE TABLE contact_us;
100
TRUNCATE TABLE customer_accounts;
101
TRUNCATE TABLE customer_accounts_history;
102
TRUNCATE TABLE customer_tokens;
103
TRUNCATE TABLE documents;
104
TRUNCATE TABLE documents_history;
105
TRUNCATE TABLE email_verifies;
106
TRUNCATE TABLE face_landmarks;
107
TRUNCATE TABLE facecompares;
108
TRUNCATE TABLE fatca_knowledges;
109
TRUNCATE TABLE fatca_knowledges_history;
110
TRUNCATE TABLE fatca_w8s;
111
TRUNCATE TABLE fatca_w8s_history;
112
TRUNCATE TABLE fatca_w9s;
113
TRUNCATE TABLE fatca_w9s_history;
114
TRUNCATE TABLE informations;
115
TRUNCATE TABLE informations_history;
116
TRUNCATE TABLE investment_occupations;
117
TRUNCATE TABLE investment_occupations_history;
118
TRUNCATE TABLE investor_types;
119
TRUNCATE TABLE investor_types_history;
120
TRUNCATE TABLE livenesses;
121
TRUNCATE TABLE mobile_verifies;
122
TRUNCATE TABLE password_history;
123
TRUNCATE TABLE pep_watchlist;
124
TRUNCATE TABLE refund;
125
TRUNCATE TABLE review_kyc_history;
126
TRUNCATE TABLE risk_groups;
127
TRUNCATE TABLE suit_test_results;
128
TRUNCATE TABLE suit_test_results_history;
129
TRUNCATE TABLE thaid_infos;
130
TRUNCATE TABLE thaid_logs;
131
TRUNCATE TABLE thaiqr;
132
TRUNCATE TABLE totps;
133
TRUNCATE TABLE transactions;
134
135
-- =============================================================================
136
-- Database: icos
137
-- =============================================================================
138
USE icos;
139
140
TRUNCATE TABLE addresses;
141
TRUNCATE TABLE assets;
142
TRUNCATE TABLE company_members;
143
TRUNCATE TABLE details;
144
TRUNCATE TABLE documents;
145
TRUNCATE TABLE faqs;
146
TRUNCATE TABLE icos;
147
TRUNCATE TABLE infos;
148
TRUNCATE TABLE invests;
149
TRUNCATE TABLE invoices;
150
TRUNCATE TABLE issuance_terms;
151
TRUNCATE TABLE issuer_infos;
152
TRUNCATE TABLE key_informations;
153
TRUNCATE TABLE token_details;
154
155
-- =============================================================================
156
-- Database: paymentapis
157
-- =============================================================================
158
USE paymentapis;
159
160
TRUNCATE TABLE withholding_tax_informations;
161
162
-- =============================================================================
163
-- Re-enable foreign key checks
164
-- =============================================================================
165
SET FOREIGN_KEY_CHECKS = 1;
166
167
-- =============================================================================
168
-- Summary:
169
-- - Total databases: 5
170
-- - Total tables truncated: 153
171
-- =============================================================================
172
173
-- NOTE: Review the changes before committing. Ensure that you have backups if necessary.
174
-- Commit transaction to finalize changes,
175
-- COMMIT;
176
-- Rollback transaction if needed,
177
-- ROLLBACK;
178
```