`

How to work with database objects

 
阅读更多

A statement that creates a new user for a database

 

CREATE USER ap IDENTIFIED BY ap;

 

 

A statement that grants privileges to a user

 

GRANT ALL PRIVILEGES TO ap;

 

 

A statement that creates a new table

 

CREATE TABLE invoices
(
	invoice_id            NUMBER, 
	vendor_id             NUMBER          NOT NULL,
	invoice_number        VARCHAR2(50)    NOT NULL,
	invoice_date          DATE            NOT NULL,
	invoice_total         NUMBER(9,2)     NOT NULL,
	payment_total         NUMBER(9,2)                 DEFAULT 0,
	credit_total          NUMBER(9,2)                 DEFAULT 0,
	terms_id              NUMBER          NOT NULL,
	invoice_due_date      DATE            NOT NULL,
	payment_date          DATE,
	CONSTRAINT invoices_pk 
		PRIMARY KEY (invoice_id),
	CONSTRAINT invoices_fk_vendors
		FOREIGN KEY (vendor_id) 
		REFERENCES vendors (vendor_id),
	CONSTRAINT invoices_fk_terms
		FOREIGN KEY (terms_id) 
		REFERENCES terms (terms_id)
);

 

A statement that adds a new column to a table

 

ALTER TABLE invoices
ADD balance_due NUMBER(9,2);

 

A statement that deletes the new column

 

ALTER TABLE invoices
DROP COLUMN balance_due;

 

 

A statement that creates an index on the table

 

CREATE INDEX invoices_vendor_id_index
ON invoices(vendor_id);

 

A statement that deletes the new index

 

DROP INDEX invoices_vendor_id_index;

 

A statement that creates a sequence for generating invoice_id values

 

CREATE SEQUENCE invoice_id_seq START WITH 115 INCREMENT BY 1;
分享到:
评论

相关推荐

    Beginning C# 2008 Databases From Novice to Professional

    A comprehensive tutorial on both SQL Server 2005 and ADO.NET 3.0, Beginning C# 2008 Databases explains and demonstrates how to create database objects and program against them in both T–SQL and C#....

    Firebird Maestro 17.1 带破解

    Database profiles give you the opportunity to connect to databases in one touch and work with the selected databases only. Powerful database object management Firebird Maestro provides you with an...

    C#学习的101个经典例子

    Framework - How-To Work with XML Framework - Key Benefits Framework - Partitioning your application Framework - role based security with Enterprise Services Framework - Scoping, Overloading, ...

    Beginning Ruby on Rails

    * How to work with HTML controls, use models in Rails applications, and work with sessions * Details on working with databases and creating, editing, and deleting database records * Methods for ...

    PHP Objects, Patterns, and Practice(Apress,2016)

    How to work with object fundamentals: writing classes and methods, instantiating objects, creating powerful class hierarchies using inheritance. Master advanced object-oriented features, including ...

    Beginning.JSON.1484202031

    How to work with JSON Data transmission via Ajax Incorporate Handlebars templates into your development Get up and running with NodeJS Perform HTTP requests to a local Web Server Implement a NoSQL ...

    Pro SQL Server Internals

    Improve your ability to develop, manage, and troubleshoot SQL Server solutions by learning how different components work “under the hood,” and how they communicate with each other. The detailed ...

    Pro LINQ: Language Integrated Query in C# 2010 (含源码)

    How to use LINQ to Objects to query in-memory data collections such as arrays, ArrayLists, and Lists to retrieve the data you want. Why some queries are deferred, how a deferred query can bite you, ...

    Learning Spring 5.0

    Gradually, you will learn the core elements of Aspect-Oriented Programming and how to work with Spring MVC and then understand how to link to the database and persist data configuring ORM, using ...

    hibernate_reference.pdf

    - **Working the Association**: This covers how to manipulate associated objects and ensure that changes are correctly synchronized with the database. - **Collection of Values**: This introduces the ...

    Oracle Database 10g PL-SQL Programming

    ### Oracle Database 10g PL/SQL ... From basic concepts to advanced features, this resource equips readers with the knowledge necessary to effectively utilize PL/SQL for database application development.

    Learning PostgreSQL 10

    Connect your Python applications to a PostgreSQL database and work with the data efficiently Test your database code, find bottlenecks, improve performance, and enhance the reliability of the ...

    PostgreSQL.for.Data.Architects.1783288604

    Discover how to design, develop, and maintain your database application effectively with PostgreSQL About This Book Understand how to utilize the most frequently used PostgreSQL ecosystem-related ...

    Introducing the MySQL 8 Document Store

    The book gives insight into how features work and how to apply them to get the most out of your MySQL experience. The book covers topics such as: The headline feature in MySQL 8 MySQL's answer to ...

    VB编程资源大全(英文源码 数据库)

    <END><br>53,ADOclient-side.zip In a network environment, open a connection to a database, retrieve data, close the connection, work with the data, reopen the connection to communicate with the ...

Global site tag (gtag.js) - Google Analytics