/ W3SCHOOLS

W3schools - SQL_INDEX / VIEW

이 페이지는 다음에 대한 공부 기록입니다
Lecture에서 배웠던 내용을 복습하며 작성했습니다

찾으시는 정보가 있으시다면
주제별reference를 이용하시거나
우측 상단에 있는 검색기능을 이용해주세요

INDEX

Is used to create indexes in tables

Are used to retrieve data from the database more quickly than otherwise

User can’t see the indexes, they are just used to speed up searches/queries

  • Updating a table with indexes takes more time than updating a table without(because the indexes also need an update), So only create indexes on columns that will be frequently searched against
CREATE INDEX index_name
ON table_name(column(s));

AUTO INCREMENT Field

Allows a unique number to be generated automatically when a new record is inserted into a table

Often this is the primary key field that we would like to be created automatically every time a new record is inserted

-- Have to create an auto-increment field with the sequence object
CREATE SEQUENCE seq_name
MINVALUE n
START WITH n
INCREMENT BY n
CACHE n;
-- it specifies how many sequence values will be stored in memory for faster access

-- To insert a new record into the table, we will have to use the nextval function
INSERT INTO table(column(s))
VALUES (seq_name.nextval, column(s));
-- This function retrieves the next value from seq_name sequence

VIEW

Is a virtual table based on the result-set of an SQL statement

Always shows up-to-date data, The DB engine recreates the view, every time a user queries it

CREATE VIEW view_name AS
SELECT column(s)
FROM table
WHERE condition;
-- Can be updated with the ‘CREATE OR REPLACE VIEW’

SQL Injection

Is a code injection technique that might destroy DB

Is one of the most common web hacking techniques

Is the placement of malicious code in SQL statements, via web page input

It usually occurs when you ask a user for input, the user gives you an SQL statement that you will unknowingly run on your DB

Hosting

If you want your web site to be able to store and retrieve data from a DB, your web server should have access to a database-system that uses the SQL lang

If your web server is hosted by an ISP(Internet Service Provider) you will have to look for SQL hosting plans

The most common SQL hosting DB are MS SQL Server, Oracle, MySQL, and MS Access