Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
Table:
CREATE TABLE t1 (
c1 VARCHAR2(100 CHAR) DEFAULT 'SOME DATA' NOT NULL,
c2 DATE DEFAULT SYSDATE NOT NULL,
c3 NUMBER DEFAULT 10 NOT NULL);
Select:
BEGIN
FOR c IN (SELECT * FROM user_tab_columns WHERE table_name = 'T1') LOOP
DBMS_output.put_line('"' || c.data_default || '"');
END LOOP;
END;
Result:
"'SOME DATA' "
"SYSDATE "
"10 "
Why there are spaces at the end of DATA DEFAULT? I need to compare data default in Oracle dictionnary with data default in project metadata, but this space ruins comparison.
EDIT: @GordonLinoff asks "Is the extra character really a space?"
Due to LONG datatype of DATA_DEFAULT column I have found only one test:
DECLARE
l_ret VARCHAR2(32000);
l_dump VARCHAR2(32000);
BEGIN
FOR c IN (SELECT * FROM user_tab_columns WHERE table_name = 'T1') LOOP
DBMS_output.put_line('"' || c.data_default || '"');
l_ret := c.data_default;
SELECT dump(l_ret)
INTO l_dump
FROM dual;
DBMS_output.put_line(l_dump);
END LOOP;
END;
Result:
"10 "
Typ=1 Len=3: 49,48,32
"SYSDATE "
Typ=1 Len=8: 83,89,83,68,65,84,69,32
"'SOME DATA' "
Typ=1 Len=12: 39,83,79,77,69,32,68,65,84,65,39,32
So, it is a space (32).
long. Is the extra character really a space or might it just look like one?create tablestatements were executed correctly according to specification. This should be done upfront, before any actual data is populated in the tables. Do you now understand what difference that makes? You don't want to wait until you populate data, and only then see if the defaults look ok.