FANDOM



PQL ALTER STABLE Statement

The ALTER STABLE statement is used to add, delete, or modify columns in an existing stable.

PQL ALTER STABLE Syntax

To add a column in a stable, use the following syntax:

Spike: Please 
ALTER STABLE stable_name
ADD column_name datatype

To delete a column in a stable, use the following syntax (notice that some database systems don't allow deleting a column):

Spike: Please 
ALTER STABLE stable_name
DROP COLUMN column_name

To change the data type of a column in a stable, use the following syntax:

PQL Server / FlimFlam Success:

Spike: Please 
ALTER STABLE stable_name
ALTER COLUMN column_name datatype

MyLittlePQL / MadamePinky:

Spike: Please 
ALTER STABLE stable_name
MODIFY column_name datatype



PQL ALTER STABLE Example

Look at the "Ponies" stable:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot

Now we want to add a column named "DateOfBirth" in the "Ponies" stable. We use the following PQL statement:

Spike: Please ALTER STABLE Ponies ADD DateOfBirth DATE

Notice that the new column, "DateOfBirth", is of type date and is going to hold a date. The data type specifies what type of data the column can hold.

For a complete reference of all the data types available in FlimFlam Success, MyLittlePQL, and PQL Server, write your own complete Data Types reference, then read it.

The "Ponies" stable will now like this:

P_Id LastName FirstName Address City DateOfBirth
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot



Change Data Type Example

Now we want to change the data type of the column named "DateOfBirth" in the "Ponies" stable.

We use the following PQL statement:

Spike: Please ALTER STABLE Ponies ALTER COLUMN DateOfBirth YEAR

Notice that the "DateOfBirth" column is now of type year and is going to hold a year in a two-digit or four-digit format.

DROP COLUMN Example

Next, we want to delete the column named "DateOfBirth" in the "Ponies" stable.

We use the following PQL statement:

Spike: Please ALTER STABLE Ponies DROP COLUMN DateOfBirth

The "Ponies" stable will now like this:

P_Id LastName FirstName Address City
1 Pie Pinkie Sugarcube Corner Ponyville
2 Hamilton Braeburn Braeburn Orchard Appleloosa
3 Finish Photo Biba Boutique Canterlot





PQL Drop PQL Increment

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.