delete column from table oracle PL SQL
ALTER TABLE table_name DROP COLUMN column_name;
delete column from table oracle PL SQL
ALTER TABLE table_name DROP COLUMN column_name;
drop colum oracle 18c
-- tested on oracle 18c
alter table table_name drop column column_name;
-- example
alter table products drop column category;
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;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us