Table Name and column naming rules
1. It must start with a letter
2. The length cannot exceed 30 characters
3. Oracle reserved words cannot be used
4, can only use A-Z, A-Z, 0-9, $, # and so on
Data Type
Character Type:
Char can query up to 2000 characters in length.
Varchar2 (20) is a string of up to 4000 characters.
Clob (character large object) Large Object Type up to 4 GB
Number Type:
In the range of-10, the power is 38 to the power of 10, which can be an integer or decimal.
Number (5, 2) indicates that a decimal number has five valid digits and two decimal places.
Number (5) indicates a five-digit integer.
Date type:
Date includes year, month, day, hour, minute, and second
Timestamp
Image:
Blob binary data, which can store pictures/sounds for 4 GB
Create a table:
SQL> Create Table student (
2 XH number (4), -- Student ID
3 XM varchar2 (20), -- name
4 sex char (2), -- Gender
5 birthday date, -- birthday
6 Sal number (7,2) -- scholarship amount
7 );
Add a field:
Alter table student add (classid number (2 ));
Modify the length of a field:
Alter table student modify (XM varchar2 (30 ));
Modify the type or name of a field (data is not allowed ):
Alter table student modify (XM char (30 ));
Delete a field:
Alter table student drop column Sal;
Modify the table name:
Rename student to Stu;
Delete table:
Drop table student;
Insert data:
Insert into student values (1, 'xiaoming ', 'male', '20-August 8-88', '192. 25', 12 );
Into must have
Date: day-month-year
Alter session set nls_date_format = 'yyyy-mm-dd ';
Insert some fields:
Insert null value: NULL
Select * from student where birthday is null;
Delete data:
Delete from student; logs are written, recoverable, and slow.
Truncate table student; delete all the records in the table. The table structure is still in progress. If no logs are written, the deleted records cannot be retrieved, which is fast.
Savepoint A; // savepoint B; A is overwritten by default.
Rollback to;