4D v13.4

Data Definition Language

Home

 
4D v13.4
Data Definition Language

Data Definition Language  


 

 

Using the SQL Data Definition Language (DDL), you can define and manage the database structure.
With DDL commands, you can create or alter tables and fields, as well as add and/or remove data.

Here is a simple example that creates a table, adds a few fields, then fills those fields with some data.

 Begin SQL
    DROP TABLE IF EXISTS ACTOR_FANS;
       
    CREATE TABLE ACTOR_FANS
       
    (ID INT32,
    Name VARCHAR);
         
    INSERT INTO ACTOR_FANS
    (ID, Name)
    VALUES(1, 'Francis');
           
    ALTER TABLE ACTOR_FANS
    ADD Phone_Number VARCHAR;
       
    INSERT INTO ACTOR_FANS
    (ID, Name, Phone_Number)
    VALUES (2, 'Florence', '01446677888');
           
 End SQL


To test the above example, in the main window of the "4D SQL Code Samples" database, press the DDL button.

Note: This example will only work once because if you press the "DDL" button a second time, you will get an error message telling you that the table already exists.

 
PROPERTIES 

Product: 4D
Theme: Tutorial