Answers for "alter table to drop a column in oracle"

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
1

oracle alter table delete column

alter table table_name drop column column_name;
alter table table_name drop (column_name1, column_name2);
Posted by: Guest on April-21-2021

Code answers related to "alter table to drop a column in oracle"

Code answers related to "SQL"

Browse Popular Code Answers by Language