24 lines
		
	
	
		
			442 B
		
	
	
	
		
			PL/PgSQL
		
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			442 B
		
	
	
	
		
			PL/PgSQL
		
	
	
	
| pragma foreign_keys = 0;
 | |
| 
 | |
| begin;
 | |
| attach database 'baseball-raw.db' as 'raw';
 | |
| 
 | |
| create temp table franchises as
 | |
| select * from "raw".teamsfranchises;
 | |
| 
 | |
| update franchises
 | |
| set active = 'N'
 | |
| where active = 'NA';
 | |
| 
 | |
| CREATE TABLE IF NOT EXISTS main."franchises" (
 | |
| 	"ID"	TEXT,
 | |
| 	"name"	TEXT,
 | |
| 	"active"	TEXT	check ("active" in ('Y','N')),
 | |
| 	"NAassoc"	TEXT,
 | |
| 	PRIMARY KEY("ID")
 | |
| );
 | |
| 
 | |
| insert into main.franchises
 | |
| select distinct * from temp."franchises";
 | |
| commit;
 |