Question:
Give some example of sql ?
anonymous
2011-08-16 08:11:50 UTC
Sql
Five answers:
anonymous
2011-08-16 08:23:43 UTC
DataBase Tutorials:



Step-by-step guides to using databases: http://www.geekgirls.com/menu_databases.htm

Beginner Tutorials: http://www.sql.org/sql-database/sql-tutorial/

Programming and Database Tutorials: http://www.thinkbrown.com/programming/

Oracle Database 10g Express Edition Tutorial: http://st-curriculum.oracle.com/tutorial/DBXETutorial/index.htm

Microsoft Access: http://databases.about.com/od/tutorials/Tutorials.htm

Tutorial on Database Concepts, SQL using MySQL: http://www.atlasindia.com/sql.htm

SQL Tutorial: http://www.w3schools.com/SQl/default.asp

SQL Tutorial: http://www.sql-tutorial.net/

SQL Command Reference: http://www.baycongroup.com/sql_command_reference.htm

SQL Tutorial - Commands: http://www.tizag.com/sqlTutorial/sqlcommands.php



More...
TheMadProfessor
2011-08-16 15:26:41 UTC
SQL has 3 subclasses of queries:



DDL (database definition language) - these are the queries that create, modify and destroy the database objects themselves (tables, indexes, triggers, etc.) Some examples are CREATE TABLE, ALTER TABLE and DROP TABLE.



DML (database manipulation language) - these are the queries most people think of when you mention SQL and are used to insert, delete, modify and retrieve the data within tables. The query verbs here are SELECT, INSERT, UPDATE and DELETE.



DCL (database control language) - these are the verbs GRANT and REVOKE which control which users can access which database objects and what actions they are authorized to perform.
Safal
2011-08-16 15:26:04 UTC
for Embedded SQL C Program Example

Embedded C program to do the following:

Starting with a station name (Denver, in this example), look up the station ID.

Print the station ID.

List all rows for that station ID.

shows single-row select and use of cursor

note that all C-language variables used in SQL statements are declared in the DECLARE SECTION.

note that all SQL statements begin with the syntax EXEC SQL and terminate with a semicolon.



#include

#include

EXEC SQL BEGIN DECLARE SECTION;



long station_id;

long mon;

float temp;

float rain;

char city_name[21];

long SQLCODE;

EXEC SQL END DECLARE SECTION;

main()

{

/* the CONNECT statement, if needed, goes here */

strcpy(city_name,"Denver");

EXEC SQL SELECT ID INTO :station_id

FROM STATION

WHERE CITY = :city_name;

if (SQLCODE == 100)

{

printf("There is no station for city %s\n",city_name);

exit(0);

}

printf("For the city %s, Station ID is %ld\n",city_name,station_id);

printf("And here is the weather data:\n");

EXEC SQL DECLARE XYZ CURSOR FOR

SELECT MONTH, TEMP_F, RAIN_I

FROM STATS

WHERE ID = :station_id

ORDER BY MONTH;

EXEC SQL OPEN XYZ;

while (SQLCODE != 100) {

EXEC SQL FETCH XYZ INTO :mon, :temp, :rain;

if (SQLCODE == 100)

printf("end of list\n");

else

printf("month = %ld, temperature = %f, rainfall = %f\n",mon,temp,rain);

}

EXEC SQL CLOSE XYZ;

exit(0);

}



Execution log:

For the city Denver, Station ID is 44

And here is the weather data:

month = 1, temperature = 27.299999, rainfall = 0.180000

month = 7, temperature = 74.800003, rainfall = 2.110000

end of list





return to SQL Table of Contents
anonymous
2011-08-16 15:16:20 UTC
CREATE TABLE customer (First_Name char(50), Last_Name char(50), Address char(50), City char(50), Country char(25), Birth_Date date)
Ben C
2011-08-16 15:15:18 UTC
I used these kind of websites see source quite a bit at uni good for tutorials and demos?



Which DBMS are you using e.g. MySQL, PostgreSQL etc.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...