Describes how to create and manage data tables, data tables are just containers of data, and tables without any data are meaningless. The mainstream database system provides tools to manage the database, use these tools to view the data in the table, and add, modify, and delete data from the table, but using tools for adding and removing data is usually limited to testing the database, and more commonly when using a program or web Page to issue SQL statement directives to the database to do so, this chapter describes ways to change the data in the table by adding and deleting SQL statements.
In this chapter we will use some data tables, in order to make it easier to run the examples in this chapter, you must first create the data tables you need, so the following is a list of the SQL statements that you will use in this chapter to create a data table:
Mysql:
CREATETABLE T_person (FNameVARCHAR (20), Fage int,fremark VARCHAR ( Span class= "Hljs-number" >20), primary key (FName)); create table T_Debt (FNumber varchar (20), Famount DECIMAL (10,2) not Null,fperson varchar (20), PRIMARY key (fnumber), foreign KEY (Fperson) references T_person (FName));
MSSQLServer:
CREATETABLE T_person (FNameVARCHAR (20), Fage int,fremark VARCHAR ( Span class= "Hljs-number" >20), primary key (FName)); create table T_Debt (FNumber varchar (20), Famount NUMERIC (10,2) not Null,fperson varchar (20), PRIMARY key (fnumber), foreign KEY (Fperson) references T_person (FName));
Oracle:
CREATE TABLE T_person (FName VARCHAR2), Fage number (ten), Fremark VARCHAR2 (+),PRIMARY KEY (FName)); CREATE TABLE t_debt (fnumber VARCHAR2), Famount NUMERIC (2) Notnull,fperson VARCHAR2 (a),PRIMARY key (Fnumber),FOREIGN key (Fperson) REFERENCES T_person (FName));
DB2:
CREATETABLE T_person (FNameVARCHAR (20)NotNull,fageInt,fremarkvarchar (20), PRIMARY key (FName)); create TABLE T_Debt (FNumber Span class= "Hljs-keyword" >varchar (20) not null,famount decimal (10, 2) not null,fperson varchar (20), primary key (fnumber), foreign KEY ( Fperson) references T_person (FName));
Run the appropriate SQL statement in a different database system. T_person is the data table that records the personnel information, where the primary key field fname is the person's name, Fage is the age, and Fremark is the memo information; T_DEBT records the debt information, where the primary key field Fnumber is the debt number, Famount is the amount owed, The Fperson field is the debtor's name, and the Fperson field establishes a foreign key association relationship with the FName field in T_person.
Data deletion and modification _ preparation data