02|Oracle learning (data type, DDL)

1. Data type:

  • Usually: character type, numeric type, date type, and large field type
  • Large field type: store large data and files. character type insert image description here
    insert image description here
    insert image description here
    When storing large data, basically blob is enough.

2. DDL (Database Definition Language)

  • It mainly includes the operation of creating, deleting and modifying database objects.
  • DDL operation:
    • Create
    • Drop (delete)
    • Alter (Modify)

2.1 create create data table syntax

insert image description here

2.1.1 Case demonstration

insert image description here

  CREATE TABLE "TB_STUDENTS" (	
    "STU_NUM" CHAR(5) NOT NULL ENABLE, 
	"STU_NAME" VARCHAR2(10) NOT NULL ENABLE, 
	"STU_SEX" CHAR(1) NOT NULL ENABLE, 
	"STU_AGE" NUMBER(2,0), 
	"STU_TEL" CHAR(11)
   ) ;

2.2 Use the Alter statement to modify the data table

2.2.1 Adding columnsinsert image description here

  • Add a stu_email column to the tb_students table:
ALTER TABLE tb_students ADD stu_email char(50);

2.2.2 Modify the column (here demonstrates modifying the type in the column and changing it to varchar)

  • Modify the type in stu_email in the tb_students table:
ALTER TABLE tb_students MODIFY stu_email varchar2(60);

2.2.3 Delete column

  • Delete the stu_email column in the tb_students table:
ALTER TABLE tb_students DROP COLUMN stu_email;

2.3 Use the DROP statement to delete the data table

insert image description here

  • Delete the student information table tb_students:
DROP TABLE tb_students;

2.4 Delete table data & delete data table

  • Delete table data, delete the data stored in the data table, and retain the structure of the data table
    • Truncate table table_name
    • delete [from] table_name
  • Delete the data table, delete the table structure (the data in the table will also be deleted at the same time)
    • Drop table table_name

Guess you like

Origin blog.csdn.net/qq_41714549/article/details/132035813