27 Haziran 2019 Perşembe

ALTER TABLE

Giriş
ALTER TABLE veya DROP COLUMN sadece metadata ile ilgilidir. Açıklaması şöyle.
There are certain circumstances where dropping a column can be a meta-data-only operation. The column definitions for any given table are not included in each and every page where rows are stored, column definitions are only stored in the database metadata, including sys.sysrowsets, sys.sysrscols, etc.

When dropping a column that is not referenced by any other object, the storage engine simply marks the column definition as no longer present by deleting the pertinent details from various system tables. When a query subsequently references that table, it skips the bytes stored in each page for that column, as if the column no longer exists.

When a subsequent DML operation occurs against the table, the pages that are affected are re-written without the data for the dropped column. If you rebuild a clustered index or a heap, all the bytes for the dropped column are naturally not written back to the page on disk. This effectively spreads the load of dropping the column over time, making it less noticeable.
Örnek
Sütuna "default değer" ve "NOT NULL" vermek için şöyle yaparız.
ALTER TABLE table_name
  MODIFY (column_1 varchar2(100) DEFAULT 'some default' NOT NULL,
          column_2 varchar2(75) DEFAULT 'Some Value' NOT NULL);

25 Haziran 2019 Salı

BLOB

Örnek
Açıklaması şöyle.
Notice that the binary literal format on Oracle is different than MySQL. This is another reason that you should avoid using binary literals in SQL statements to make your Java program portable.
Şöyle yaparız.
Statement sta = con.createStatement();

// Inserting CLOB value with a regular insert statement
int count = sta.executeUpdate(
        "INSERT INTO Image"
        +" (ID, Subject, Body)"
        +" VALUES (1, '"+subject+"'"
        +", 'C9CBBBCCCEB9C8CABCCCCEB9C9CBBB')"); //Oracle format
//      +", 0xC9CBBBCCCEB9C8CABCCCCEB9C9CBBB)"); //SQL Server format
//      +", x'C9CBBBCCCEB9C8CABCCCCEB9C9CBBB')"); // MySQL format

18 Haziran 2019 Salı

TO_CHAR Metodu

Örnek
Şöyle yaparız.
Select TO_CHAR(sysdate,'dd-mm-yyyyy') from dual;