2014년 11월 11일 화요일

mysql 데이터 용량 확인

SELECT
concat(table_schema,'.',table_name),  
concat(round(table_rows/1000000,2),'M') rows,  
concat(round(data_length/(1024*1024*1024),2),'G') DATA,  
concat(round(index_length/(1024*1024*1024),2),'G') idx,  
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,  
round(index_length/data_length,2) idxfrac   
FROM information_schema.TABLES 
where table_name = 'TN_MM_PRDUCT_MTTR_DISTB_QY_D' ;

2014년 11월 3일 월요일

mysql oracle 유사 명령어

-- 포트

mysql : 3306
oracle : 1521

-- DB 접속

shell > mysql --user=user_name --password=your_password db_name
shell > mysql -u user_name -p password db_name

shell > sqlplus username/password@db_name


-- DB내 존재하는 테이블 검색

mysql> show tables;
oracle> select * from tabs;


-- 결과수 제한

mysql> select * from table where ROWNUM < 10;
oracle > select * from table limit 10;


-- NULL 처리

mysql> select IFNULL(field1, 0) from table;
oracle> select NVL(field1, 0) from table;


-- 현재시간

mysql> select now() from dual;
oracle> select sysdate from dual;


-- if-else 구문

mysql> select if(field=1, 'X','Y') from table;
oracle> select decode(field,1,'X','Y') from table;