orcle增删改操作及alter修改表字段操作
orcle增删改操作:操作前确保当前用户有增删改的权限。
--创建表 create table itcast( pid number(10), pname varchar2(10) ); drop table itcast; --复制表 create table product1 as select * from product; --表重命名 alter table product1 rename to product;
--插入数据 insert into itcast(pid,pname) values (2,'xxx'); commit; insert into itcast(pid,pname) values (1,'xxx'); commit;
--更新数据 update itcast set pid=3 where pname='xxx';
--删除数据 delete from itcast where pid=2;
--修改表 --增加字段 alter table itcast add(address varchar2(10)); --修改表字段 alter table itcast modify(address varchar2(20)); --删除表字段 alter table itcast drop column address; --字段重命名 alter table itcast rename column addres to address; --表重名 --alter table 表名 rename to 新表名
-- 删除表 --删除表中所有记录 delete from itcast; --删除表 drop table itcast; --删除表再创建表 truncate table itcast;
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步