Oracle 基本SQL语句
create table A( aid number(2) not null,aname varchar2(4),asal number(7,2) );
insert into a(aid,aname,asal) values(1,‘张三‘,1000.5); insert into a values(1,‘张三‘,1000.5);
update <表名> set <列名=更新值> [where <更新条件>]
【删除<满足条件的>行数据】delete from <表名> [where <删除条件>] 例:delete from a where name=‘开心朋朋‘(删除表a中列值为开心朋朋的行) 【删除整个表数据】truncate table <表名> 例:truncate table tongxunlu 【删除整个表】drop table 表名称 例:drop table? a;
select *? from a; select 字段? from 表名? where 条件
alter table tablename add (column datatype [default value][null/not null],….); 说明:alter table 表名 add (字段名 字段类型 默认值 是否为空); 例:alter table sf_users add (HeadPIC blob); 例:alter table sf_users add (userName varchar2(30) default ‘空‘ not null);
alter table tablename modify (column datatype [default value][null/not null],….); 说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空); 例:alter table sf_InvoiceApply modify (BILLCODE number(4));
alter table tablename drop (column); 说明:alter table 表名 drop column 字段名; ?例:alter table sf_users drop column HeadPIC;
说明:alter table 表名 rename column 列名 to 新列名 (其中:column是关键字) 例:alter table sf_InvoiceApply rename column PIC to NEWPIC;
说明:alter table 表名 rename to 新表名 例:alter table sf_InvoiceApply rename to sf_New_InvoiceApply;
1.第一种情况 1》如果2张表的字段一致,并且希望插入全部数据,可以用这种方法: INSERT INTO 目标表 SELECT * FROM 来源表; 2》比如要将 articles 表插入到 newArticles 表中,则是: INSERT INTO newArticles SELECT * FROM articles; 3》如果只希望导入指定字段,可以用这种方法: INSERT INTO 目标表 (字段1,字段2,...) SELECT 字段1,... FROM 来源表; 2.第二种情况 1》如果将一个表的数据放在另外一个不存在的表: 2》如果只希望导入指定字段,可以用这种方法: select 字段1,字段2,... into 目标不存在的表 from 来源表 (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |