Oracle? Get rid of CHAR and VARCHAR datatypes and use VARCHAR2 instead.
SQL> CREATE TABLE STUDENT
2 ( STUDENT_NAME VARCHAR2(20),
3 FATHER_NAME VARCHAR2(20),
4 ENROLL_NO NUMBER(12),
5 PHONE_NO NUMBER(12),
6 EMAIL_ID VARCHAR2(20),
7 ADDRESS VARCHAR2(20),
8 COURSE VARCHAR2(20),
9 D_O_B DATE
10 );
Table created.
SQL>
Apart from that, that table doesn't have a primary key defined and - in my opinion - it should. A few NOT NULL
constraints (for example, on STUDENT_NAME) might be a good choice.
On a second thought, why STUDENT_NAME? It isn't normalized - should be split to (at least) STUDENT_FIRST_NAME and STUDENT_LAST_NAME.
Someone (@Vikash, who posted a message 3 hours ago)) said that Oracle doesn't support INT
datatype; well, it does, but you'd rather use NUMBER:
SQL> create table test
2 (phone_no int);
Table created.
but you can't set its precision:
SQL> create table test_2
2 (phone_no int(12));
(phone_no int(12))
*
ERROR at line 2:
ORA-00907: missing right parenthesis
SQL>
so - in your code - use either INT
or NUMBER(12)
, but beware of unexpected traps (i.e. rounding), such as
SQL> create table test
2 (num1 int,
3 num2 number(12));
Table created.
SQL> insert into test values (123.456, 123.456);
1 row created.
SQL> select * From test;
NUM1 NUM2
---------- ----------
123 123
SQL>