sql statement creates table

Tip: After the article is written, the table of contents can be automatically generated. For how to generate it, please refer to the help document on the right.


Preface

        哈喽大家好,随着科技的发达,国家的强大,人类智慧的增长。我们的身边也越来越多所谓的人工智能,但是他们所谓的智能也是我们人类去进行编程代码,进行设定功能和各种精密的传感器来进行的。自然软件的开发也就成了不可缺少的重要部分。下面我们要讲的是oracle数据库的应用之一的如何给创建用户,因为呢orcale的原理是一个数据库,用户不能自己去建只能用开发者给的。所以需要我们给用户进行权限的设置。


提示:以下是本篇文章正文内容,下面案例可供参考

1. What is oracle?

Oracle Database, also known as Oracle RDBMS, or simply Oracle. It is a relational database management system from Oracle Corporation. It is a product that has always been in the leading position in the database field. It can be said that the Oracle database system is a popular relational database management system in the world. The system has good portability, easy use, and strong functions. It is suitable for various large, medium, and small computer environments. It is a database solution that is efficient, reliable and adaptable to high throughput.

        The ORACLE database system is a set of software products with a distributed database as the core provided by the American ORACLE company (Oracle). It is one of the most popular client/server (CLIENT/SERVER) or B/S architecture databases. For example, SilverStream is a kind of middleware based on database. ORACLE database is the most widely used database management system in the world. As a general database system, it has complete data management functions; as a relational database, it is a complete relational product; as a distributed database, it implements distributed processing functions. But all its knowledge, as long as you learn ORACLE knowledge on one model, you can use it on various types of machines.

        The latest version of Oracle database is Oracle Database 20c. Oracle Database 12c introduces a new multi-tenant architecture that makes it easy to deploy and manage database clouds. In addition, some innovative features can maximize resource utilization and flexibility, such as Oracle Multitenant to quickly integrate multiple databases, while Automatic Data Optimization and Heat Map can compress and tier data with higher density. These unique technology advancements, coupled with major enhancements in availability, security and big data support, make Oracle Database 12c an ideal platform for private and public cloud deployments.

2. Usage steps

1. Create a new table

        We use SQL statements to create three new tables, namely the book table, the orders table, and the orderitem table. First, set the id as the primary key.

      The next step is to set the string type, the type is varchar2(); this is the String type. NOT NULL means non-empty. Can not be empty

The following is the integer type, number();

The code is as follows (example):

创建book表
create table book(
id number(11) primary key,
bookname VARCHAR2(50) NOT NULL,
price NUMBER(11,2) NOT NULL,
storage NUMBER(11) NOT NULL
);
--创建orders表
CREATE TABLE orders(
id NUMBER(11) PRIMARY KEY,
total NUMBER(11,2) DEFAULT 0,
create_time DATE NOT NULL,
status CHAR(1) DEFAULT 0
);
--创建orderitem表
CREATE TABLE orderitem(
id NUMBER(11) PRIMARY KEY,
book_id NUMBER(11),
price NUMBER(11,2) NOT NULL,
num NUMBER(11) DEFAULT 1,
order_id NUMBER(11),
constraint book_fk foreign KEY(book_id) REFERENCES book(id),
CONSTRAINT order_fk FOREIGN KEY(order_id) REFERENCES orders(id)
);

2. Read data

The code is as follows (example):

--创建orders表
CREATE TABLE orders(
id NUMBER(11) PRIMARY KEY,
total NUMBER(11,2) DEFAULT 0,
create_time DATE NOT NULL,
status CHAR(1) DEFAULT 0
);
--创建orderitem表
CREATE TABLE orderitem(
id NUMBER(11) PRIMARY KEY,
book_id NUMBER(11),
price NUMBER(11,2) NOT NULL,
num NUMBER(11) DEFAULT 1,
order_id NUMBER(11),
constraint book_fk foreign KEY(book_id) REFERENCES book(id),
CONSTRAINT order_fk FOREIGN KEY(order_id) REFERENCES orders(id)
);

The oracle software used here.


Summarize

Here is a summary of the article:
For example: The above is what I will talk about today. This article only briefly introduces the use of oracle. The latest version of Oracle database is Oracle Database 20c. Oracle Database 12c introduces a new multi-tenant architecture that makes it easy to deploy and manage database clouds. In addition, some innovative features can maximize resource utilization and flexibility, such as Oracle Multitenant to quickly integrate multiple databases, while Automatic Data Optimization and Heat Map can compress and tier data with higher density. These unique technological advancements, coupled with major enhancements in availability, security and big data support, make Oracle Database 12c an ideal platform for private and public cloud deployments
—————————————— ——Copyright
Statement: This article is an original article by CSDN blogger "Fusu without Gray Hair" and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement when reprinting.

Guess you like

Origin blog.csdn.net/qq_68384595/article/details/127235238