Database
[Postgressql] 다건 Insert ( Multi Row Insert )
헤르메스의날개
2024. 2. 25. 08:49
728x90
PostgreSQL 에서 다건 Insert 를 찾아봤습니다.
개발환경
PostgrSQL : 14.1
https://www.postgresql.org/docs/current/sql-insert.html
일반적인 Insert 문
INSERT INTO users (name, email) VALUES ('John', 'john@example.com');
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
INSERT INTO users (name, email) VALUES ('Bob', 'bob@example.com');
다건 Insert 문 ( PostgreSql 11 버전 이후에서 된다고 합니다. )
INSERT INTO users (name, email) VALUES
('John', 'john@example.com'),
('Alice', 'alice@example.com'),
('Bob', 'bob@example.com');
Excel 을 읽어서 String 으로 변경
public String convString(Cell cell) {
String returnValue = "";
switch( cell.getCellType() ) {
case STRING:
returnValue = cell.getStringCellValue();
break;
case NUMERIC:
returnValue = String.format( "%.0f", cell.getNumericCellValue() );
break;
case BOOLEAN:
returnValue = cell.getBooleanCellValue() ? "Y" : "N" ;
break;
case FORMULA:
returnValue = cell.getCellFormula().toString() ;
break;
default:
returnValue = cell.getStringCellValue();
}
return returnValue;
}
postgresql 오류: 캐시된 계획에서 결과 형식을 바꾸지 않아야 함
오류가 나는데 해결은 못하고 있음.
plan_cache_mode 관련 검색이 되는데, 확실치 않음.
ALTER DATABASE [DB명] SET plan_cache_mode = force_generic_plan
728x90