Answers for "oracle drop collumn"

SQL
1

oracle drop column

ALTER TABLE my_table DROP COLUMN my_col;
-- To check if column exists before renaming it:
DECLARE
    l_cnt INTEGER;
BEGIN
    SELECT count(*) INTO l_cnt
    FROM dba_tab_columns		-- or all_tab_columns (depending on grants)
    WHERE owner = 'my_schema' AND table_name = 'my_table' 
    	AND column_name = 'my_col';
    IF (l_cnt = 1) THEN
        EXECUTE IMMEDIATE 'ALTER TABLE my_schema.my_table DROP COLUMN my_col';
    END IF;
END;
Posted by: Guest on May-04-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language