首页 > 代码库 > 初学oracle,sql,DML向表中插入某个值

初学oracle,sql,DML向表中插入某个值

SQL> conn scott/tiger
Connected.
SQL> show user;
USER is "SCOTT"
SQL> create table qq(name varchar2(10),salary number(8,2)); 创建一个表qq,两个段,名字和工资
Table created.
SQL> select * from qq;  查询表qq的信息
no rows selected
SQL> insert into qq(name) values(‘zhangsan‘); 指定某个队列插入数据,未设置NULL
1 row created.
SQL> select * from qq;
NAME           SALARY
---------- ----------
zhangsan
                        插入数据,尝试发现,NUMBER数值8,2表示,小数点保持两位,六位的整数位
           values2为字符型,汉子一个字代表两个字节,英文及特殊字符一个,我这汉子显示不出来,字符汉字括号内加引号
SQL> insert into qq(salary) values(123456.78);
1 row created.
SQL> select * from qq;
NAME           SALARY
---------- ----------
zhangsan
            123456.78
SQL> insert into qq values(‘lisi‘,12345678);
insert into qq values(‘lisi‘,12345678)
                             *ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column
SQL> insert into qq values(‘lisi‘,5000);
1 row created.
SQL> select * from qq;
NAME           SALARY
---------- ----------
zhangsan
            123456.78
lisi             5000
SQL> insert into qq values(1);
insert into qq values(1)
            *ERROR at line 1:
ORA-00947: not enough values
SQL> insert into qq(salary) values(11);
1 row created.
SQL> select * from qq;
NAME           SALARY
---------- ----------
zhangsan
            123456.78
lisi             5000
                   1

SQL> roll                              回滚操作
Rollback complete.
SQL> select * from qq;

no rows selected

1

 

初学oracle,sql,DML向表中插入某个值