Saturday , 23 January 2021
Stackode
Home > MySql

MySql

How to delete index in MySql

How to delete index in MySql, first you need to know the exact name of the INDEX (Unique key in this case) to delete or update it. INDEX names are usually same as column names. In case of more than one INDEX applied on a column, MySQL automatically suffixes numbering to the column names to create unique INDEX names. For ...

Read More »

Drop or Delete Database

Drop or Delete Database statement is used to drop an existing database in SQL schema. Syntax: Basic syntax of DROP DATABASE statement is as follows: DROP DATABASE DatabaseName; Always database name should be unique within the RDBMS. Example: If you want to delete an existing database <testDB>, then DROP DATABASE statement would be as follows: SQL> DROP DATABASE testDB; NOTE: ...

Read More »

Constraints – SQL

Constraints – SQL – Constraints are the rules enforced on data columns on table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database. Constraints could be column level or table level. Column level constraints are applied only to one column, whereas table ...

Read More »

Using Sequences – SQL

Using Sequences – SQL is a set of integers 1, 2, 3, … that are generated in order on demand. Sequences are frequently used in databases because many applications require each row in a table to contain a unique value, and sequences provide an easy way to generate them. This chapter describes how to use sequences in MySQL. Using AUTO_INCREMENT ...

Read More »

Select Database, Use Statement – SQL

Select Database, Use Statement – SQL When you have multiple databases in your SQL Schema, then before starting your operation, you would need to select a database where all the operations would be performed. The SQL USE statement is used to select any existing database in SQL schema. Syntax: Basic syntax of USE statement is as follows: USE DatabaseName; Always ...

Read More »

Using Joins – SQL

Using Joins – SQL is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each. Consider the following two tables, (a) CUSTOMERS table is as follows: +----+----------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+----------+-----+-----------+----------+ | 1 ...

Read More »

Handling Duplicates – SQL

Handling Duplicates – SQL may be a situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only unique records instead of fetching duplicate records. The SQL DISTINCT keyword, which we already have discussed, is used in conjunction with SELECT statement to eliminate all the duplicate records and fetching only ...

Read More »

Create Table – SQL

Create Table – SQL involves naming the table and defining its columns and each column’s data type. The SQL CREATE TABLE statement is used to create a new table. Syntax: Basic syntax of CREATE TABLE statement is as follows: CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) ); CREATE ...

Read More »

UNIONS CLAUSE – SQL

UNIONS CLAUSE – SQL is used to combine the results of two or more SELECT statements without returning any duplicate rows. To use UNION, each SELECT must have the same number of columns selected, the same number of column expressions, the same data type, and have them in the same order, but they do not have to be the same ...

Read More »

Injection SQL

Injection SQL – If you take user input through a webpage and insert it into a SQL database, there’s a chance that you have left yourself wide open for a security issue known as SQL Injection. This lesson will teach you how to help prevent this from happening and help you secure your scripts and SQL statements in your server ...

Read More »