일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- math
- Java
- numpy
- matplotlib
- Redshift
- 파이썬
- Mac
- GIT
- array
- django
- list
- Google Spreadsheet
- PySpark
- google apps script
- Excel
- Tkinter
- Kotlin
- hive
- string
- PANDAS
- c#
- dataframe
- Google Excel
- Python
- PostgreSQL
- Github
- gas
- SQL
- Apache
- Today
- Total
목록create table (3)
달나라 노트
Pandas로 DataFrame을 다루다보면 DataFrame data를 database에 load해야 할 경우가 있습니다. 따라서 아래처럼 create table 구문을 실행시켜 database table을 생성하고 해당 tabe에 insert하는 방법을 사용한다고 가정해봅시다. create table test_table ( col1 varchar, col2 bigint, col3 double ) 위 예시는 column이 3개밖에 없어서 다행이지만 만약 column이 30개인 DataFrame을 insert하려고 한다면 위 create table syntax에 column 30개에 대한 datatype을 일일이 적어줘야 할것입니다. 이는 너무 번거로운 작업이 아닐 수 없죠. pandas에는 위처럼 특정..
create table test_schema.test_table ( col1 varchar(max), col2 bigint(max), col3 varchar(max) ) ; create table은 위처럼 테이블을 생성시킬 수 있도록 합니다. 위 테이블은 col1, col2, col3라는 3개의 column을 가질 것이고, 각 컬럼에 들어갈 값들의 datatype은 순서대로 varchar(문자), bigint(정수), varchar(문자)입니다. create table if not exists test_schema.test_table ( col1 varchar(max), col2 bigint(max), col3 varchar(max) ) ; 또한 if not exists라는 옵션을 추가할 수도 있습니다...
drop table if exists test_temporary_table; create temporary table test_temporary_table as select current_date ; select * from test_temporary_table ; -> 결과 : 2020-12-17 drop table if exists test_temporary_table; drop table table_name은 어떤 이름의 테이블을 삭제하는데 사용됩니다. 여기에 if exists라는 키워드를 붙이면 해당 테이블이 존재한다면 삭제하고 존재하지않는다면 그냥 넘어가게됩니다. 즉, 존재하지 않는 테이블을 drop하려할 때 생기는 에러를 방지할 수 있죠. create temporary table test_te..