๐Ÿ’ป Programming (356)

๋ง๊ทธ๋Œ€๋กœ ์ฝค๋งˆ๊ฐ€ ๋ˆ„๋ฝ๋˜์—ˆ๋‹ค๋Š” ์–˜๊ธฐ๋‹ค.  

ํ•˜์ง€๋งŒ!!!!! ๋•Œ๋กœ๋Š” ์—‰๋šฑํ•œ ์‹ค์ˆ˜์— ์—‰๋šฑํ•œ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๊ธฐ๋„ ํ•œ๋‹ค.

 

๋‚ด๊ฐ€ ์ € ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋ฅผ ๋ณธ๊ฒƒ์€ ์•„๋ž˜์™€ ๊ฐ™์€ ์„ค์ •์„ ํ–ˆ์„๋•Œ๋‹ค.

์Šคํ”„๋ง ๊ธฐ๋ฐ˜ ์›น์•ฑ์„ ๋งŒ๋“ค๊ณ  xmlํŒŒ์ผ์— ์ฟผ๋ฆฌ๋ฌธ์„ ๋„ฃ์—ˆ๋Š”๋ฐ....

 

================================================ 

<insert id="add">
        insert into
            ํ…Œ์ด๋ธ”๋ช…
        values(
            column1 = #{col1, jdbcType=VARCHAR}
            ,โ€‹column2 = #{col2, jdbcType=VARCHAR}
            ,โ€‹column3 = #{col3, jdbcType=VARCHAR}
        )
</insert> 

================================================

์ž, ์—ฌ๊ธฐ์„œ ํ…Œ์ด๋ธ”๋ช…๊ณผ ์ปฌ๋Ÿผ๋ช…์€ ์ž„์˜๋กœ ์จ๋„ฃ์—ˆ๋‹ค. ๋ฌผ๋ก  ์‹ค์ œ ์†Œ์Šค์—์„œ๋Š” ์‹ค์ œ ํ…Œ์ด๋ธ”๋ช…๊ณผ ์ปฌ๋Ÿผ๋ช…์ด ๋“ค์–ด๊ฐ€์žˆ๋‹ค. ์ด ํ…Œ์ด๋ธ”์—๋Š” ์„ธ๊ฐœ์˜ ์ปฌ๋Ÿผ( column1, column2, column3 )์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•œ๋‹ค. 

 

์ด ์ฝ”๋“œ์—์„œ ์™œ ๋ˆ„๋ฝ๋œ ์ฝค๋งˆ ๋ˆ„๋ฝ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ์ฐพ์•˜๋Š”๊ฐ€???

 

์ด ์ฝ”๋“œ์—๋Š” ์ฝค๋งˆ๊ฐ€ ๋ˆ„๋ฝ๋œ ๊ฒƒ์ด ์•„๋‹ˆ๋‹ค. Insert ๋ฌธ์˜ ํ˜•์‹์ž์ฒด๊ฐ€ ํ‹€๋ ธ๋‹ค.

์œ„ ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐ”๋€Œ์–ด์•ผ ํ•œ๋‹ค.

 

        insert into
            ํ…Œ์ด๋ธ”๋ช…
        values(
            #{col1, jdbcType=VARCHAR}
            ,โ€‹#{col2, jdbcType=VARCHAR}
            ,โ€‹#{col3, jdbcType=VARCHAR}
        ) 

 

์—๋Ÿฌ๋ฉ”์‹œ์ง€๋งŒ๋ณด๊ณ  ์ฝค๋งˆ๊ฐ€ ์–ด๋””๊ฐ€ ๋ˆ„๋ฝ๋๋‹ค๋Š”๊ฑฐ์ง€? ๋ผ๋Š” ์ƒ๊ฐ์„ ๊ฐ€์ง€๊ณ  ์˜ค๋ฅ˜๋ฅผ ์ฐพ์œผ๋ คํ•œ๋‹ค๋ฉด ํ•˜๋ฃจ์ข…์ผ์„ ํ—ˆ๋น„ํ•ด๋„ ๋ชป์ฐพ์„ ๊ฒƒ์ด๋‹ค.

 

๋‹น์‹ ์˜ ์ง€์‹์— ์กฐ๊ธˆ์ด๋‚˜๋งˆ ๋„์›€์ด ๋๊ธฐ๋ฅผ ๋ฐ”๋ผ๋ฉฐ ๊ธ€์„ ๋งˆ์นœ๋‹ค.... 


์•„๋ž˜ ์˜ˆ์ œ๋Š” JMNote.com์˜ ์œ„ํ‚คํŽ˜์ด์ง€์—์„œ ๋ณต์‚ฌํ•ด์˜จ ๊ฒƒ์ž„์„ ๋ฐํž™๋‹ˆ๋‹ค.

( ์›๋ณธ ์ฃผ์†Œ - 

http://jmnote.com/wiki/%EC%98%A4%EB%9D%BC%ED%81%B4_%EC%BB%AC%EB%9F%BC%EB%AA%85_%EC%88%9C%EC%84%9C_%EB%B3%80%EA%B2%BD

์‹ค์Šต ํ…Œ์ด๋ธ” ์ƒ์„ฑ

CREATE TABLE employee (
emp_no NUMBER PRIMARY KEY,
dept VARCHAR2 (16),
name VARCHAR2 (32)
);
INSERT INTO employee VALUES (130001, '์ธ์‚ฌ๋ถ€', 'ํ™๊ธธ๋™');
INSERT INTO employee VALUES (130002, '์˜์—…๋ถ€', '์ž„๊บฝ์ •');
INSERT INTO employee VALUES (130003, '์ƒ์‚ฐ๋ถ€', '์žฅ๊ธธ์‚ฐ');

๋ณ€๊ฒฝ ์ „

SELECT * FROM employee;
EMP_NO  DEPT    NAME
130001  ์ธ์‚ฌ๋ถ€       ํ™๊ธธ๋™
130002  ์˜์—…๋ถ€       ์ž„๊บฝ์ •
130003  ์ƒ์‚ฐ๋ถ€       ์žฅ๊ธธ์‚ฐ

๋ณ€๊ฒฝ

  • ์žฌ๋ฐฐ์—ด๋œ ์‚ฌ๋ณธ ์ƒ์„ฑ โ†’ ์‚ฌ๋ณธ์„ ์›๋ณธ์œผ๋กœ ๋Œ€์ฒด
CREATE TABLE temp AS SELECT emp_no, name, dept FROM employee;
DROP TABLE employee;
RENAME temp TO employee;

๋ณ€๊ฒฝ ํ›„

SELECT * FROM employee;
EMP_NO  NAME    DEPT
130001  ํ™๊ธธ๋™       ์ธ์‚ฌ๋ถ€
130002  ์ž„๊บฝ์ •       ์˜์—…๋ถ€
130003  ์žฅ๊ธธ์‚ฐ       ์ƒ์‚ฐ๋ถ€


์˜ค๋ผํด์—์„œ ํ…Œ์ด๋ธ”์— ์ƒˆ๋กœ์šด PRIMARY KEY๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์ด๋ฅผ FK๋กœ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ์‹ถ์—ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‹ค๊ฐ€ ๊ทธ๋งŒ ORA-02270 ์—๋Ÿฌ๋ฅผ ๋งŒ๋‚˜๊ฒŒ ๋˜์—ˆ๋‹ค.

๋งŒ๋‚˜๊ฒŒ ๋œ ์ƒํ™ฉ์€ ์ด๋ ‡๋‹ค.

 

ํ…Œ์ด๋ธ” A์™€ B๊ฐ€ ์žˆ๋‹ค.

ํ…Œ์ด๋ธ” A๋Š” a๋ผ๋Š” PK๊ฐ€ ์žˆ๊ณ  ํ…Œ์ด๋ธ” B๋Š” (a, b)๋ฅผ ๋ณตํ•ฉPK๋กœ ๊ฐ€์ง€๊ณ  ์žˆ์—ˆ๋‹ค.

์ž, ์—ฌ๊ธฐ์„œ A์™€ Bํ…Œ์ด๋ธ”์— ์ปฌ๋Ÿผc๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ๋ณตํ•ฉPK๋กœ ๋งŒ๋“ค์–ด์ฃผ๋ คํ–ˆ๋‹ค.

์ฆ‰, A์˜ PK๋Š” (a, c), ๊ทธ๋ฆฌ๊ณ  B์˜ PK๋Š” (a, b, c)๊ฐ€ ๋˜๋Š”๊ฒƒ์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  B์˜ a, c๋Š” FK๋กœ A์˜ a, c๋ฅผ ์ฐธ์กฐํ•ด์•ผํ•œ๋‹ค.

 

์ด๋ฅผ ํ•˜๊ธฐ์œ„ํ•ด์„œ ์ƒ๊ฐํ–ˆ๋˜ ์ˆœ์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค. 

 

1. ํ…Œ์ด๋ธ” A, B์˜ PK๋ฅผ DROPํ•œ๋‹ค.

2. ํ…Œ์ด๋ธ” A, B์— ์ปฌ๋Ÿผc๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

3. ํ…Œ์ด๋ธ” A์˜ PK๋กœ (a, c)๋ฅผ ์„ ์–ธํ•œ๋‹ค. 

3. ํ…Œ์ด๋ธ” B์˜ a๋ฅผ FK๋กœ ์„ ์–ธํ•˜๋ฉด์„œ A์˜ a๋ฅผ ์ฐธ์กฐํ•˜๋„๋ก ํ•œ๋‹ค.

 - alter table B add foreign key (a) references A(a);

4. ํ…Œ์ด๋ธ” B์˜ c๋ฅผ FK๋กœ ์„ ์–ธํ•˜๋ฉด์„œ A์˜ c๋ฅผ ์ฐธ์กฐํ•˜๋„๋ก ํ•œ๋‹ค.

 - alter table B add foreign key (c) references A(c);

5. ํ…Œ์ด๋ธ” B์˜ PK๋กœ (a, b, c)๋ฅผ ์„ ์–ธํ•œ๋‹ค.

 

ํ•˜์ง€๋งŒ 3๋ฒˆ์—์„œ 02270 ์—๋Ÿฌ๋ฅผ ๋งŒ๋‚˜๊ฒŒ ๋˜์—ˆ๋‹ค.

์ด ์—๋Ÿฌ๋Š” UNIQUE KEY๋‚˜ PK๊ฐ€ ์•„๋‹Œ๊ฒƒ์„ ์ฐธ์กฐํ•˜๋ ค๊ณ  ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์ด๋‹ค.

๊ทธ๋ž˜์„œ ์ƒ๊ฐํ•ด๋ณด๋‹ˆ ํ…Œ์ด๋ธ” A์˜ PK๋Š” a๋‚˜ c๊ฐ€ ์•„๋‹Œ (a, c)์ธ ๊ฒƒ์ด๋‹ค.

ํ•˜์—ฌ 3, 4๋ฒˆ ๊ณผ์ •์„ ๋ฌถ์–ด์„œ ํ…Œ์ด๋ธ” B์˜ FK๋กœ B์˜ (a, c)๊ฐ€ A์˜ (a, c)๋ฅผ ์ฐธ์กฐํ•˜๋„๋ก ์„ค์ •ํ•˜์˜€๋”๋‹ˆ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜์—ˆ๋‹ค.

 - alter table B add foreign key (a, c) references A(a, c);


๐Ÿ’ป Programming/Oracle 11g

[SQL] Truncate vs Drop vs Delete

DELETE

The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.

 

TRUNCATE

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.

 

DROP

The DROP command removes a table from the database. All the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. The operation cannot be rolled back.  

 

 

* DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.


ALTER TABLE [DB๋ช…] MODIFY([์ปฌ๋Ÿผ๋ช…] NOT NULL);

 

๊ฐ„๋‹จํ•˜๋‹ค!!!!!!!!!!

 

ํ™”์ดํŒ…!!! 


์˜ค๋ผํด์—์„œ ํ•œ๋ฒˆ์— ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ ˆ์ฝ”๋“œ๋ฅผ insertํ•˜๋ ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

INSERT ALL
INTO ํ…Œ์ด๋ธ”๋ช… ( column_1, column_2 ) VALUES ( value_1,  value_2)

INTO ํ…Œ์ด๋ธ”๋ช… ( column_1, column_2 ) VALUES ( value_3,  value_4)

SELECT 1 FROM DUAL


๐Ÿ’ป Programming/Oracle 11g

[SQL] COUNT(*) ์™€ COUNT(1)

SQL์—์„œ ํŠน์ • ๋ฐ์ดํƒ€์˜ ๊ฐœ์ˆ˜๋ฅผ ๋ฝ‘์•„๋‚ผ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” COUNT()ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

๋ญ ๋ฐ์ดํ„ฐ์˜ ์–‘์ด ์ ์€ ๊ฒฝ์šฐ์—๋Š” ์†๋„์ฐจ์ด๋ฅผ ๋Š๋ผ์ง€ ๋ชปํ•˜๊ฒ ์ง€๋งŒ ๋ฐ์ดํ„ฐ์˜ ์–‘์ด ๋งŽ์€ DB๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์–ด๋–จ๊นŒ...????ํ•˜๋Š” ์˜๋ฌธ์ด ์ƒ๊ธด๋‹ค.

 

์•„์ง ํ™•์‹คํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด์ง€๋Š” ์•Š์•˜๋‹ค. ๊ทธ์ € ์ธํ„ฐ๋„ท์—์„œ ์ฐพ์€ ์ •๋ณด์— ์˜ํ•˜๋ฉด....

 

์˜์–ด์— ์•ฝํ•œ๋ถ„๋“ค์€ Example๋ถ€๋ถ„์€ ๊ทธ๋ƒฅ ๊ฑด๋„ˆ๋›ฐ๊ณ  Tip: Performance......๋ถ€๋ถ„์„ ๋ณด๋ฉด๋œ๋‹ค. 

================================================================= 

Example - Using SQL GROUP BY Clause

In some cases, you will be required to use the SQL GROUP BY clause with the SQL COUNT function.

For example, you could use the SQL COUNT function to return the name of the department and the number of employees (in the associated department) that make over $25,000 / year.

SELECT department, COUNT(*) AS "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department;

Because you have listed one column in your SQL SELECT statement that is not encapsulated in the SQL COUNT function, you must use the SQL GROUP BY clause. The department field must, therefore, be listed in the GROUP BY section.

TIP: Performance Tuning with SQL COUNT

Since the SQL COUNT function will return the same results regardless of what NOT NULL field(s) you include as the SQL COUNT function parameters (ie: within the brackets), you can change the syntax of the SQL COUNT function to COUNT(1) to get better performance as the database engine will not have to fetch back the data fields.

For example, based on the example above, the following syntax would result in better performance:

SELECT department, COUNT(1) AS "Number of employees"
FROM employees
WHERE salary > 25000
GROUP BY department;

Now, the SQL COUNT function does not need to retrieve all fields from the employees table as it had to when you used the COUNT(*) syntax. It will merely retrieve the numeric value of 1 for each record that meets your criteria.

======================================================================== 

 

 

 

์ถœ์ฒ˜ :Http://www.techonthenet.com/sql/count.php


java.lang.SecurityException: Sealing violation exception (ID 6554602)

Description

Starting with JDBC 10.2 drivers, having more than one JDBC jar file in the CLASSPATH may result in a java.lang.SecurityException: Sealing violation exception.

Detailed explanation from Oracle is documented in the following Oracle Document ID:

Note:405446.1
Subject: JDBC Driver 10.2 Uses Sealed JAR files and May Cause SecurityException Sealing Violation

Solution

(Suggested by Oracle) Make sure that the CLASSPATH includes only one JDBC driver JAR file.

=============================================================================


๐Ÿ’ป Programming/Oracle 11g

[SQL] CONNECT BY , START WITH

๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง„ ๋ฐ์ดํƒ€๋ฅผ ๋ฝ‘์•„๋ณด์ž!!!!

ํ•œ ํ…Œ์ด๋ธ” Table_1์ด ์žˆ๋‹ค.

์ด ํ…Œ์ด๋ธ”์€ objectIDํ•„๋“œ์™€ parentObjectID ํ•„๋“œ๋ฅผ ๊ฐ–๊ณ  ์žˆ๋‹ค.

๋‘ ํ•„๋“œ์—๋Š” OBJECT_X(X๋Š” ์ •์ˆ˜ํ˜• ์ˆซ์ž)ํ˜•์‹์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด์žˆ๋‹ค. 

๋˜, OBJECT_1์ด ํ•˜์œ„ OBJECT_2๋ฅผ ๊ฐ€์ง€๊ณ  OBJECT_2๊ฐ€ ๋˜ ํ•˜์œ„ OBJECT_3์„ ๊ฐ€์ง„๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. (OBJECT_2๋Š” OBJECT_1์˜ ์ž์‹ OBJECT๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด๋œ๋‹ค.)

์—ฌ๋Ÿฌ ๋‹ค๋ฅธ OBJECT_X ํ˜•์‹์˜ ๋ฐ์ดํ„ฐ๋“ค์ด ํ…Œ์ด๋ธ” ๋‚ด์— ๋งŽ์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž.

 

์ด๋•Œ CONNECT BY์™€ START WITH๋ฅผ ์ด์šฉํ•˜์—ฌ OBJECT_2์™€ ๊ทธ ์ƒ์œ„, ๋˜ ๊ทธ ์ƒ์œ„, ๋˜ ๊ทธ ์ƒ์œ„...์ญˆ์šฐ์šฑ ํ•ด์„œ OBJECT_2๋ฅผ ๊ฐ–๋Š” ์ตœ์ƒ์œ„ OBJECT๊นŒ์ง€ ๊ณ„์ธต๊ตฌ์กฐ๋กœ ๋ฝ‘์•„๋‚ด๊ธฐ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ํ•˜๋ฉด ๋œ๋‹ค.

 

SELECT *

FROM Table_1

CONNECT BY PRIOR objectID = parentObjectID

START WITH objectID = 'OBJECT_2'

 

------- 

 ํŒŒ๋ž€์ƒ‰ ์กฐ๊ฑด๋ถ€์˜ ์ˆœ์„œ๊ฐ€ ๋ฐ”๋€Œ๋ฉด ๊ฒฐ๊ณผ๋„ ๋ฐ”๋€Œ๋ฏ€๋กœ ์ฃผ์˜ํ•˜์ž.!!!!


SQL ์ฟผ๋ฆฌ์—์„œ ๊ฒฐ๊ณผ๋กœ ๋ฆฌ์ŠคํŠธ๊ฐ€ ๋‚˜์™”์„ ๋•Œ ์ด ๋ฆฌ์ŠคํŠธ๋“ค์„ ํ•œ์ค„(1 row)๋กœ ํ•ฉ์ณ์„œ ๋ณด์—ฌ์ฃผ๊ณ  ์‹ถ๋‹ค๋ฉด!!!!!

LISTAGG๋ฅผ ์‚ฌ์šฉํ•˜์ž!! 

SELECT LISTAGG(last_name, '; ')
         WITHIN GROUP (ORDER BY hire_date, last_name) "Emp_list",
       MIN(hire_date) "Earliest"
  FROM employees
  WHERE department_id = 30;

Emp_list                                                     Earliest
------------------------------------------------------------ ---------
Raphaely; Khoo; Tobias; Baida; Himuro; Colmenares            07-DEC-02


SQL join์„ ํ•  ๊ฒฝ์šฐ ์–ด๋– ํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ฌ์ง€ ์˜ˆ์ƒ์„ ํ•˜๊ณ ์„œ ์ฟผ๋ฆฌ๋ฌธ์„ ์ž‘์„ฑ์„ ํ•ด์•ผํ•œ๋‹ค.

join์˜ ์ข…๋ฅ˜๊ฐ€ ๋งŽ๊ธฐ ๋•Œ๋ฌธ์— ์ดํ•ดํ•˜๊ธฐ๊ฐ€ ํž˜๋“  ๋ถ„๋“ค์„ ์œ„ํ•ด์„œ ์ธํ„ฐ๋„ท์— ๋Œ์•„๋‹ค๋‹ˆ๋Š” ์‚ฌ์ง„์„ ํ•˜๋‚˜ ์ฒจ๋ถ€ํ•ด๋ณด์•˜๋‹ค. ๋‘ ํ…Œ์ด๋ธ”์„ ์กฐ์ธํ–ˆ์„ ๋•Œ ์–ด๋– ํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋Š”์ง€ ๊ทธ๋ฆผ์œผ๋กœ ์‰ฝ๊ฒŒ ์„ค๋ช…ํ•ด๋†“์€ ์‚ฌ์ง„์ด๋‹ค.

 

 


ORA-00031: session marked for kill

์•„๋ž˜ ๋งํฌ๋กœ ๊ฐ€๋ณด์ž.

Check the link below.



https://blog.tanelpoder.com/2009/08/13/alter-system-kill-session-and-ora-00031-session-marked-for-kill/ 


๊ฐ„๋‹จํžˆ ๋งํ•˜์ž๋ฉด ๋™์  ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์‹œ์— ์กฐ๊ฑด๋ฌธ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด์„œ์ด๋‹ค.

select * from table1; ์ด๋ผ๋Š” ์ฟผ๋ฆฌ์™€ select * from table1 where 1=1;์ด๋ผ๋Š” ์ฟผ๋ฆฌ์˜ ๊ฒฐ๊ณผ๋Š” ๋™์ผํ•˜๋‹ค.

ํ•˜์ง€๋งŒ ๋™์  ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์กฐ๊ฑด์ ˆ์— ๋˜๋‹ค๋ฅธ ์กฐ๊ฑด์€ ์ค˜์•ผํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ํ›„์ž๊ฐ€ ๋” ์ข‹๋‹ค.

์™œ???

์ฒซ๋ฒˆ์งธ ์ฟผ๋ฆฌ์— ์กฐ๊ฑด์„ ๋”ํ•˜๋ ค๋ฉด ์šฐ์„  where๊ฐ€ ์žˆ๋Š”์ง€๋ฅผ ๊ฒ€์‚ฌ๋ฅผ ํ•ด์ฃผ๊ณ  ์กฐ๊ฑด์„ ๋”ํ•ด์ฃผ์–ด์•ผ ํ•˜์ง€๋งŒ

๋‘๋ฒˆ์งธ ์ฟผ๋ฆฌ์— ์กฐ๊ฑด์„ ๋”ํ• ๋•Œ๋Š” ๋ฌด์กฐ๊ฑด and๋กœ ์‹œ์ž‘ํ•˜๋Š” ์กฐ๊ฑด์„ ๋„ฃ์–ด์ฃผ๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

์˜ˆ๋ฅผ๋“ค์–ด location='Seoul'์ด๋ผ๋Š” ์กฐ๊ฑด์„ ๋ง๋ถ™์—ฌ ์ค˜์•ผํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž.

์ฒซ๋ฒˆ์งธ ์ฟผ๋ฆฌ์— ์ € ์กฐ๊ฑด์„ ๋ถ™์ด๋ ค๋ฉด ์šฐ์„  if๋ฌธ์„ ์จ์„œ ์ฟผ๋ฆฌ์— where์ ˆ์ด ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ๋ฅผ ํ•ด์ค˜์•ผ ํ•˜์ง€๋งŒ

๋‘๋ฒˆ์งธ ์ฟผ๋ฆฌ์— ๋ถ™์ด๋ ค๋ฉด ๊ทธ๋ƒฅ sql += "and location=\'Seoul\'" ์ด๋Ÿฐ์‹์œผ๋กœ ์“ฐ๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. 


00984. 00000 -  "column not allowed here"

 

๋ฌธ์ œ๊ฐ€ ๋œ SQL๋ฌธ 

insert into tablename(field1, FIELD2, FIELD3, FIELD4, FIELD5) values("a","b","c","d",null);

 

ํ•ด๊ฒฐํ•œ SQL๋ฌธ 

insert into tablename(field1, FIELD2, FIELD3, FIELD4, FIELD5) values('a','b','c','d',null);

 

varchar2 ํƒ€์ž…์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด๊ฐ€์•ผ ํ•  ์ž๋ฆฌ์— ์ŠคํŠธ๋ง์„ ๋„ฃ์–ด์ค€๋‹ค๊ณ  ๋”๋ธ” quotation mark๋ฅผ ์ผ๋‹ค๊ฐ€ ์ €๋Ÿฐ ์—๋Ÿฌ๋ฅผ ๋ณด์•˜๋‹ค. ๊ฐ„๋‹จํžˆ ์‹ฑ๊ธ€ quotation mark๋กœ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋ฌธ์ œ ํ•ด๊ฒฐ!!! 


์•„๋ž˜ ๋‚ด์šฉ์€ ํƒ€ ๋ธ”๋กœ๊ทธ์—์„œ ํผ์˜จ๊ฒƒ์ž…๋‹ˆ๋‹ค.
์ €๋Š” CentOS 6.4 / Oracle 11g์— ์ ์šฉํ•ด๋ดค๋Š”๋ฐ ์•„๋ฌด ๋ฌธ์ œ์—†์ด ์ž˜ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.



ํ™˜๊ฒฝ
Cent OS 5.5 / Oracle 10g

------------------------------------------------------------------------------

1. ์บ๋ฆญํ„ฐ์…‹ ํ™•์ธ 

SELECT * FROM sys.props$ where name='NLS_CHARACTERSET';


2. ํ”„๋กœํŒŒ์ผ ์ˆ˜์ •

export NLS_LANG=KOREAN_KOREA.UTF-8 
export NLS_LANG=KOREAN_KOREA.KO16MSWIN949 



3. ์บ๋ฆญํ„ฐ์…‹ ๋ณ€๊ฒฝ

C:\>sqlplus /nolog; 
sql>conn /as sysdba; 

 

๋ณ€๊ฒฝํ•˜๊ณ ์žํ•˜๋Š” ์บ๋ฆญํ„ฐ์…‹์„ ์ˆ˜์ •

== UTF-8 == 
sql> update sys.props$ set value$='UTF8' where name='NLS_CHARACTERSET'; 
sql> update sys.props$ set value$='UTF8' where name='NLS_NCHAR_CHARACTERSET'; 
sql> update sys.props$ set value$='KOREAN_KOREA.UTF8' where name='NLS_LANGUAGE'; 

= KO16MSWIN949 = //ํ•œ๊ธ€ํ™•์žฅ 
sql> update sys.props$ set value$='KO16MSWIN949' where name='NLS_CHARACTERSET'; 
sql> update sys.props$ set value$='KO16MSWIN949' where name='NLS_NCHAR_CHARACTERSET'; 
sql> update sys.props$ set value$='KOREAN_KOREA.KO16MSWIN949' where name='NLS_LANGUAGE'; 
sql> commit; 

 

 

์žฌ์‹œ์ž‘

sql> shutdown immediate; 
sql> startup mount; 
sql> alter system enable restricted session; 
sql> alter system set job_queue_processes=0; 
sql> alter system set aq_tm_processes=0; 
sql> alter database open; 
sql> alter database character set UTF8; 
or alter database character set KO16MSWIN949; 
sql> shutdown immediate; 
sql> startup; 







์ถœ์ฒ˜ : http://algina.tistory.com/41

์ถœ์ฒ˜ : http://www.techonthenet.com/oracle/functions/dump.php


Oracle/PLSQL: DUMP Function

This Oracle tutorial explains how to use the Oracle/PLSQL DUMP function with syntax and examples.

Description

The Oracle/PLSQL DUMP function returns a varchar2 value that includes the datatype code, the length in bytes, and the internal representation of the expression.

Syntax

The syntax for the Oracle/PLSQL DUMP function is:

DUMP( expression, [return_format], [start_position], [length] )

Parameters or Arguments

expression is the expression to analyze.

return_format is optional. It determines the format of the return value. This parameter can be any of the following values:

ValueExplanation
8octal notation
10decimal notation
16hexadecimal notation
17single characters
1008octal notation with the character set name
1010decimal notation with the character set name
1016hexadecimal notation with the character set name
1017single characters with the character set name

start_position and length are optional parameters. They determines which portion of the internal representation to display. If these parameters are omitted, the DUMP function will display the entire internal representation in decimal notation.

Applies To

The DUMP function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle DUMP function examples and explore how to use the DUMP function in Oracle/PLSQL.

For example:

DUMP('Tech')
Result: 'Typ=96 Len=4: 84,101,99,104'

DUMP('Tech', 10)
Result: 'Typ=96 Len=4: 84,101,99,104'

DUMP('Tech', 16)
Result: 'Typ=96 Len=4: 54,65,63,68'

DUMP('Tech', 1016)
Result: 'Typ=96 Len=4 CharacterSet=US7ASCII: 54,65,63,68'

DUMP('Tech', 1017)
Result: 'Typ=96 Len=4 CharacterSet=US7ASCII: T,e,c,h'


์ตœ๊ทผ์— ์•Œ๊ฒŒ๋œ ์ง€์‹์„ ๊ณต์œ ํ•˜๊ณ ์ž ํฌ์ŠคํŒ…์„ ๋‚จ๊น๋‹ˆ๋‹ค.


์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ EUC-KR(MSWIN949)๋กœ ์ธ์ฝ”๋”ฉ์„ค์ •์ด ๋˜์–ด์žˆ๋Š” DB์— varcharํƒ€์ž…์˜ ์ปฌ๋Ÿผ์— ํ•œ๊ธ€์„ ๋„ฃ์–ด๋‘์—ˆ์Šต๋‹ˆ๋‹ค.

select dump()๋ฅผ ์ด์šฉํ•ด์„œ ๋“ค์–ด๊ฐ€์žˆ๋Š” ๋ฐ์ดํƒ€๋ฅผ ํ—ฅ์‚ฌ๊ฐ’์œผ๋กœ ์ถœ๋ ฅํ•ด๋ณด๋ฉด 2๋ฐ”์ดํŠธ์งœ๋ฆฌ๋กœ ํ•œ๊ธ€์ด ์ž˜ ๋“ค์–ด๊ฐ€์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์ž๋ฐ” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ด ๊ฐ’์„ Resultset.getBytes()๋กœ ์ฝ์–ด์™€์„œ ์ถœ๋ ฅํ•ด๋ณด๋‹ˆ 3๋ฐ”์ดํŠธ UTF-8 ์ธ์ฝ”๋”ฉ์œผ๋กœ ๋ณ€ํ™˜์ด ๋˜์–ด์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.



 


euc-kr ๋ฐ”์ดํŠธ๋ฅผ ์ฝ์–ด์™€์„œ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด ๊ฒƒ์ธ๋ฐ์š”.


์˜ค๋ผํด ๋ฌธ์„œ๋ฅผ ์ฐพ์•„๋ดค๋”๋‹ˆ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ถ€๋ถ„์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.


How JDBC Drivers Perform Globalization Support Conversions

The techniques that the Oracle JDBC drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses the US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UTF-16, which is used in Java applications, and vice versa.

If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, JA16SJIS or KO16KSC5601), then the driver converts the data first to UTF-8 (this step does not apply to the server-side internal driver), then to UTF-16. For example, the driver always converts CHAR and VARCHAR2 data in a non-US7ASCII, non-WE8ISO8859P1 character set. It does not convert RAW data.


Note:

The JDBC drivers perform all character set conversions transparently. No user intervention is necessary for the conversions to occur.

 


 


์˜ค๋ผํด ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ํ•œ๊ธ€์„ ๊ธฐ๋ณธ์ ์œผ๋กœ utf-8 ๋ฐ์ดํƒ€๋กœ ๋ณ€ํ™˜์„ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์ž๋ฐ” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ฝ์–ด๋“ค์ผ ๋•Œ Resulset.getBytes()๋กœ ์ฝ์–ด์˜ค๋ฉด utf-8๋กœ ์ธ์ฝ”๋”ฉ๋œ ๋ฐ์ดํƒ€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด์ฃ .


๊ทธ๋ž˜์„œ getBytes()ํ•˜๋Š” ๊ฒƒ์„ getString()์œผ๋กœ ๋ฐ”๊พธ๊ณ  String.getBytes(encoding) ์œผ๋กœ bytes๋ฅผ ์ฝ์–ด์˜ค๋„๋ก ๋ฐ”๊ฟ”์„œ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.






Reference : http://docs.oracle.com/cd/B10500_01/java.920/a96654/advanc.htm

์ถœ์ฒ˜ : http://www-01.ibm.com/support/docview.wss?uid=swg21222490

์ฐธ๊ณ ๋กœ  IBM์—์„œ ์ œ๊ณตํ•˜๋Š” ํž™๋คํ”„ ๋ถ„์„ํˆด์€ ์ด๊ณณ์—์„œ ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.


MusgGather : Gathering data for OutOfMemoryErrors on AIXยฎ


Problem(Abstract)

If your Java application experiences OutOfMemory(OOM) errors on an AIXยฎ operating system, there are a number of diagnostic data files that are useful for diagnosing the problem. This mustgather document describes about the diagnostic data files to be collected and the procedure to collect the same.

Resolving the problem

The following set of diagnostic data files need to be collected to diagnose an OutOfMemory error in the Java application:
1. Javacores (Multiple javacore files might be required to diagnose native memory issues)
2. Jextracted system cores (At least two system cores might be required to diagnose native memory issues)
3. Heapdumps
4. Snap traces for analyzing native OOM errors
5. Verbose GC logs (native_stderr.log)
6. Process logs (ps)

For these diagnostic data files to be created, check that the system is configured correctly as per setup document.

Please collect the diagnostic data files for an OutOfMemory error in the Java application as per the below steps:

1. Collect the javacore, heap dump and snap trace file generated automatically by Java runtime on an OOM occurrence.

2. For Java heap exhaustion issues, collect the javacore, system core, heap dump and snap trace files generated automatically by using -Xdump option mentioned in setup.

3. For native memory issues, generate at least three Java core, system core, heap dump and snap trace files by using the following command:
kill -3 [PID_of_problem_JVM]

When you observe the application starting to use excessive amounts of memory, start generating these above files at regular intervals.

The time interval between each generation of files depends on how quickly the application encounters native OOM error. For example, if the application takes 30 minutes to produce an native OOM error, issue the kill command at 10-minute intervals.

Please note that all the javacores, system cores, heap dumps and snap traces can be found in the current path and the names of them will follow the below format:
Javacore : javacore.<time stamp>.<id>.txt
Systemcore : core.<time stamp>.<id>.dmp
Snap trace : snap.<time stamp>.<id>.trc
Heap dump : heapdump.<time stamp>.<id>.phd

Run the JExtract tool against the generated system core file using the following command:
<installpath>/jre/bin/jextract [corefile]

Save the resulting archive file, which has a name in the format of core.<time stamp>.<id>.dmp.zip

4. Collect Verbose Garbage Collector data. This data is in the location specified during setup. Alternatively, the data is sent to the stderr output.

5. Collect process size monitoring data. The data is in the location specified during setup.

After collecting all the above diagnostic data files, you can submit them for help with diagnosing the problem.

Additional Information

When diagnosing the native OOM errors deeply, IBM service might ask you to collect additional information as mentioned below:

1. If the problem is suspected to be caused by a leak within the JVM, you can enable the JVM argument: -Xcheck:memory:callsite=<threshold>

This prints an allocation summary for every <threshold> allocations, by tracking calls from the JVM to the operating system memory allocation functions (malloc(), calloc(), free() and so on), along with callsite information showing which area of code requested the memory. Please use this information to track the memory allocated by an area of code that has not been freed, and to monitor how the size of that memory varies over time.

This option writes a summary of all allocations made or freed by the JVM, for every "N" allocations. "N" is typically a number in the range 100000 โ€“ 500000.The output of this option is written to stderr.

Please note the below important considerations for using the Xcheck option:
a) Only available on JDK release 5.0 and above
b) Performance can be badly affected if your threshold is set too low
c) Does not track allocations from outside the JVM

2. If the problem is suspected to be caused by Java Class Library (JCL) memory allocations, you can enable the following option:-Dcom.ibm.dbgmalloc=true

3. If operating system level debugging of native memory leaks is required, you can use the debugging extensions of the malloc subsystem of AIXยฎ. For details about using AIXยฎ debugging extensions, see the related information links.

Related information

Native Profiling on AIX



 putty์—์„œ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ SSH ์ฐฝ์„ ์—ด๋ฉด ์œ„์™€ ๊ฐ™์ด ํ•œ๊ธ€์ด ๊นจ์ ธ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ์— ํ•œ๊ธ€์ด ๊นจ์ง€์ง€ ์•Š๊ฒŒ ํ•˜๋ ค๋ฉด putty์˜ ๋ฌธ์ž ์ง‘ํ•ฉ(character set) ์„ค์ •์„ ์†๋ณด์•„์•ผ ํ•œ๋‹ค.


 

 

๋จผ์ € locale ๋ช…๋ น์œผ๋กœ SSH์—์„œ ์“ฐ์ด๋Š” ๋ถ€ํ˜ธ ์ข…๋ฅ˜๋ฅผ ์‚ดํ•€๋‹ค. ์—ฌ๊ธฐ์—์„œ๋Š” UTF-8์ด ์“ฐ์ด๊ณ  ์žˆ๋‹ค.

 


 

 

 putty ์„ค์ฉก์—์„œ Window โ†’ Translation์œผ๋กœ ๋“ค์–ด๊ฐ€๋ฉด ๋ฌธ์ž ์ง‘ํ•ฉ ์„ค์ •์ด ๋ณด์ธ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์ธ 'Use font encoding'์„ ์•ž์—์„œ ๋ณธ UTF-8๋กœ ๋ฐ”๊พผ๋‹ค.

 



 

 

์ด ์„ค์ •์„ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋‘๊ณ  ์‹ถ๋‹ค๋ฉด Session ํ•ญ๋ชฉ์—์„œ Default Settings๋กœ ์ €์žฅ(save)ํ•œ๋‹ค.

 



 

 

 

๋ฌธ์ž ์ง‘ํ•ฉ ์„ค์ •์ด ๋งž๊ฒŒ ๋˜์—ˆ๋‹ค๋ฉด ์ด์ฒ˜๋Ÿผ ๊นจ์ง€์ง€ ์•Š์€ ํ•œ๊ธ€์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 


  
์ถœ์ฒ˜ : http://pat.im/860


 


Mac OS X์—์„œ Eclipse Luna์™€ Tomcat์„œ๋ฒ„๋ฅผ ์—ฐ๋™์„ ์‹œํ‚ค๊ณ  ์›นํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๋ ค๊ณ  ํ•  ๋•Œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

์ด์œ ์ธ์ฆ‰์Šจ ์„œ๋ฒ„๋Ÿฐํƒ€์ž„ํ™˜๊ฒฝ์˜ ์„œ๋ฒ„๋ชฉ๋ก์— ํ†ฐ์บฃ์ด ์•ˆ๋‚˜์˜ค๋Š” ๊ฒƒ์ด๋‹ค.

 

ํ•ด๊ฒฐ์ฑ…์€ ๊ฐ„๋‹จํ•˜๋‹ค.

 

 Help->Install new software-> Work with : ์—๋‹ค๊ฐ€ http://download.eclipse.org/releases/luna  ์ฃผ์†Œ๋ฅผ ์น˜๋ฉด ์•„๋ž˜์ชฝ์— ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅํ•œ ์†Œํ”„ํŠธ์›จ์–ด ๋ชฉ๋ก์ด ์ญˆ์šฐ์šฐ์šฑ ๋œฐ ๊ฒƒ์ด๋‹ค.



๊ทธ๋Ÿฌ๋ฉด ์ œ์ผ ๋ฐ‘์œผ๋กœ ์Šคํฌ๋กคํ•ด์„œ Web, XML, Java EE and ์–ด์ฉŒ๊ตฌ ......์˜ ํ•˜์œ„๋ชฉ๋ก์„ ํŽผ์ณ๋ณด์ž.

๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋ชฉ๋ก์ด ๋˜ ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.


์ž ์—ฌ๊ธฐ์„œ JST Server Adapters, JST Server Adapters Extensions, JST Server UI, ๊ทธ๋ฆฌ๊ณ 
WST Server Adapters ๋ฅผ ์„ ํƒํ•˜์ž. ์•„๋ž˜๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋ง์ด๋‹ค.



์ด์ œ Next ๋ฅผ ํด๋ฆญํ•˜๊ณ  ๋ผ์ด์„ผ์Šค acceptํ•œ ๋’ค ์„ค์น˜๋ฅผ ์™„๋ฃŒํ•˜๊ณ  ์ดํด๋ฆฝ์Šค๋ฅผ ์žฌ๋ถ€ํŒ…ํ•˜๋ฉด ์„œ๋ฒ„๋Ÿฐํƒ€์ž„ํ™˜๊ฒฝ์— ํ†ฐ์บฃ์ด ๋ชฉ๋ก์— ๋œจ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์„๊ฒƒ์ด๋‹ค.

 

๋…ธ๋ ฅํ•˜๋Š” ์ž์—๊ฒŒ ๊ธฐํšŒ๊ฐ€ ์ฃผ์–ด์ง€๋‚˜๋‹ˆ~~