Oacle - ddl 생 성 표 와 관리 표
18961 단어 Oacle
--
/*
,
*/
--
SELECT * FROM user_tables;
--
SELECT * FROM user_catalog;
--
SELECT DISTINCT object_type FROM user_objects;
-- --
/*
1.
2. 1-30
3. A-Z a-z 0-9 _ $ #
4.
5. Oracle
*/
-- --
/*
*
VARCHAR2(size)*
CHAR(size)*
NUMBER(p,s)*
DATE*
LONG , 2G
CLOB , 4G
RAW(LONG RAW)
BLOB* , 4G
BFILE , 4G
ROWID
*/
-- CREATE TABLE ... , scott
-- ok
-- 1
CREATE TABLE emp1(
id NUMBER(10), -- 10 9
name VARCHAR2(20), --20
salary NUMBER(10,2), -- 2
hire_date DATE --
);
SELECT * FROM user_tables WHERE LOWER(TABLE_NAME) = 'emp1'
-- 2( )
-- ok
CREATE TABLE emp2
AS
SELECT EMPLOYEE_ID id ,LAST_NAME name,HIRE_DATE,SALARY
FROM EMPLOYEES
SELECT * FROM user_tables WHERE LOWER(TABLE_NAME) = 'emp2'
--
SELECT * FROM emp2;
/*
ALTER TABLE
1.
2.
3.
4.
5.
*/
-- emp1
-- ok
ALTER TABLE emp1
ADD(email VARCHAR2(20))
SELECT * from emp1;
-- emp1 id 15
ALTER TABLE emp1
MODIFY(id NUMBER(15))
--navicate,desc ,plsql
-- emp1 salary 2000
ALTER TABLE emp1
MODIFY(SALARY NUMBER(20,2) DEFAULT 2000)
-- emp2 name number
SELECT * FROM emp2
-- column to be modified must be empty to change datatype
ALTER TABLE emp2
MODIFY(name NUMBER(20))
-- emp1 email
-- ok
ALTER TABLE emp1
DROP COLUMN email;
-- emp1 salary sal
ALTER TABLE emp1
RENAME COLUMN SALARY to sal
-- ( )
-- emp1
DROP TABLE emp1;
-- ,
truncate TABLE emp2;
SELECT * FROM emp2;
-- update delete INSERT sql 。
rollback;
--
-- 51. myemp,
-- 1) employees employee_id(id), last_name(name), salary(sal), email
CREATE TABLE myemp
AS
SELECT EMPLOYEE_ID id,LAST_NAME name,SALARY sal,EMAIL
FROM EMPLOYEES
SELECT * from myemp
-- 2). employees ,
CREATE TABLE myemp2
AS
SELECT EMPLOYEE_ID id,LAST_NAME name,SALARY sal,EMAIL
FROM EMPLOYEES WHERE 1=2 --
SELECT * from myemp2
-- 52.
-- 1).
ALTER TABLE myemp
add(HIRE_DATE DATE DEFAULT SYSDATE)
SELECT * from myemp
-- 3).
ALTER TABLE myemp
RENAME COLUMN tdate to create_date
-- 4).
ALTER TABLE myemp
DROP COLUMN create_date
-- 53. ( : truncate), !!
truncate TABLE myemp;
-- 54.
--
-- 1). , employees , :
CREATE TABLE myemp3
AS
SELECT * FROM EMPLOYEES WHERE 1<>1
SELECT * FROM myemp3
-- 2) employees 80 emp2 :
SELECT * FROM emp2;
-- * too many values , emp2 EMPLOYEES
INSERT INTO emp2 SELECT EMPLOYEE_ID id,LAST_NAME name,HIRE_DATE,SALARY FROM EMPLOYEES WHERE DEPARTMENT_ID = 80
/*
1. dept1
name Null? type
id Number(7)
name Varchar2(25)
*/
CREATE TABLE dept1(
id NUMBER(7),
name VARCHAR2(25)
)
SELECT * FROM dept1;
-- 2. departments dept2
CREATE TABLE dept2
AS
SELECT * FROM DEPARTMENTS
SELECT * FROM dept2;
/*
3. emp5
name Null? type
id Number(7)
First_name Varchar2(25)
Last_name Varchar2(25)
Dept_id Number(7)
*/
CREATE TABLE emp5(
id NUMBER(7),
FIRST_NAME VARCHAR2(25),
LAST_NAME VARCHAR2(25),
dept_id NUMBER(7)
)
--4. Last_name 50
ALTER TABLE emp5
MODIFY(LAST_NAME VARCHAR2(50))
-- 5. employees employees2
CREATE TABLE EMPLOYEES2
AS
SELECT * FROM EMPLOYEES
SELECT * FROM EMPLOYEES2
-- 6. emp5
SELECT * FROM emp5;
DROP TABLE emp5;
-- 7. employees2 emp5
RENAME EMPLOYEES2 to emp5
-- 8. dept emp5 test_column,
SELECT * FROM dept;
SELECT * FROM emp5;
ALTER TABLE dept
add(test_column VARCHAR2(20))
ALTER TABLE emp5
add(test_column VARCHAR2(20))
--desc dept
-- 9. dept emp5 test_column ,
-- ok
ALTER TABLE DEPT
set unused COLUMN test_column
-- ok
ALTER TABLE DEPT
DROP unused COLUMN
-- ok
ALTER TABLE emp5
set unused COLUMN test_column
-- ok
ALTER TABLE emp5
DROP unused COLUMN
SELECT * FROM dept;
SELECT * FROM emp5;
-- 10. emp5 dept_id
--ok
ALTER TABLE EMP5
add(dept_id NUMBER(20))
--ok
ALTER TABLE EMP5
DROP COLUMN dept_id
SELECT * FROM emp5;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
activemq 5.5 의 입문 은 설치, 시작, 데이터베이스 지속 화 를 포함한다Apache ActiveMQ 5.5.0 은 주로 유지보수 버 전 으로 130 개가 넘 는 문 제 를 복 구 했 으 며 대부분 bug 와 개선 이 었 다. Improved performance for offline d...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.