Convert SQL Boolean Values to CSV
Extract SQL boolean columns (TRUE, FALSE, 1, 0) to CSV. Learn how different boolean representations in SQL are preserved in the CSV output.
Detailed Explanation
Boolean Values in SQL to CSV
SQL databases represent boolean values differently depending on the dialect. PostgreSQL uses TRUE/FALSE, MySQL often uses 1/0 or TINYINT(1), and SQLite uses integer 1/0. The SQL to CSV tool preserves these values exactly as they appear in the INSERT statement.
Example SQL
CREATE TABLE feature_flags (
id INTEGER PRIMARY KEY,
feature_name VARCHAR(100) NOT NULL,
is_enabled BOOLEAN DEFAULT FALSE,
is_beta BOOLEAN DEFAULT FALSE,
rollout_percentage INTEGER DEFAULT 0
);
INSERT INTO feature_flags VALUES
(1, 'dark_mode', TRUE, FALSE, 100),
(2, 'new_dashboard', TRUE, TRUE, 50),
(3, 'ai_suggestions', FALSE, TRUE, 10),
(4, 'export_pdf', TRUE, FALSE, 100),
(5, 'batch_processing', FALSE, FALSE, 0);
Generated CSV
id,feature_name,is_enabled,is_beta,rollout_percentage
1,dark_mode,TRUE,FALSE,100
2,new_dashboard,TRUE,TRUE,50
3,ai_suggestions,FALSE,TRUE,10
4,export_pdf,TRUE,FALSE,100
5,batch_processing,FALSE,FALSE,0
Boolean Representations
| SQL Input | CSV Output | Notes |
|---|---|---|
TRUE |
TRUE |
PostgreSQL style |
FALSE |
FALSE |
PostgreSQL style |
true |
true |
Case preserved |
1 |
1 |
MySQL/SQLite style |
0 |
0 |
MySQL/SQLite style |
NULL |
(depends on setting) | Missing boolean |
The tool preserves the original casing and format. If you need to normalize booleans (e.g., convert all to true/false), you can post-process the CSV or use the CSV to JSON converter for further transformation.
Use Case
Exporting feature flag configurations, user permission tables, or system settings where boolean columns need to be reviewed or compared in a spreadsheet.