Vous êtes sur la page 1sur 4

1) create table Employee (EmployeeID varchar2(10) primary key, LastName varchar2(20), FirstName varchar2(20), Address varchar2(50), DateHired date);

Note: I have chosen the datatypes arbitrarily since it was not mentioned 2) insert into Employee values('E100','ghose','chandroma','29, Beadon Row Kolkat a-700006','15-Apr-2012'); insert into Employee values('E109','mishra','chandan','24, Beadon Row Kolkata-70 0006','18-Apr-2012'); insert into Employee values('E110','ray','Amit','29, SDR Street Kolkata-700008', '25-Apr-2012'); 3) At the sql prompt when we type: Select * from Employee; It displays the above entered information in a tabular format and shows 3 row(s) selected. 4) create table Client (ClientID varchar2(10) primary key, LastName varchar2(20), FirstName varchar2(20), Balance number(6,2), EmployeeID varchar2(10)); 5) insert into Client values('C100','ghose','chandroma','5468.23','E100'); insert into Client values('C109','mishra','chandan','7000.06','E109'); insert into Client values('C110','ray','Amit','2970.08','E110'); 6) At the sql prompt when we type: Select * from Client; It displays the above entered information in a tabular format and shows 3 row(s) selected. 7) option d - create table 8) option b - deletes the table structure along with the table data 9) Data types in SQL Server are organized into the following categories: a) b) c) d) e) f) g) Exact numerics Unicode character strings Approximate numerics Binary strings Date and time Other data types Character strings

In SQL Server, based on their storage characteristics, some data types are desig nated as belonging to the following groups: Large value data types: varchar(max), nvarchar(max), and varbinary(max) Large object data types: text, ntext, image, varchar(max), nvarchar(max), varbin ary(max), and xml

Exact Numerics ---------------bigint numeric bit smallint decimal smallmoney int tinyint money Approximate Numerics -----------------------float real Date and Time ---------------------date datetimeoffset datetime2 smalldatetime datetime time Character Strings -----------------------char varchar text Unicode Character Strings -------------------------------nchar nvarchar ntext Binary Strings -----------------------------binary varbinary image Other Data Types ---------------------------cursor timestamp hierarchyid uniqueidentifier sql_variant xml

table 10) DDL, the data definition language is used to manipulate the data structures and even the tables. They are, Create, Alter, Rename, drop and truncate. DML ,the data manipulation language is used to make changes to the existing data in tha tables. They are, Insert, Update, Delete and Merge. 11) "LIKE" is the operator used in pattern matching. It has to used with two attributes 1. % - means matches zero or more characters 2. _ ( underscore ) - means mathing exactly one character Eg - SELECT * FROM EMP WHERE EMP_NAME LIKE 'A%'; 12) IS NULL operator. SELECT * FROM EMP WHERE COMMISSION IS NULL; 13) START or @. 14) & is used for this purpose. 15) RUN. 16) _ for single character substitution and % for multi-character substitution. 17) True. 18) True 19) Insert, update, delete, select, references, index, execute, alter, all. 20) REVOKE. 21)` USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD 22) USER_CONSTRAINTS 23) The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transacti on to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire. Example:SQL> SELECT COUNT(*) FROM emp; COUNT(*) ---------14 SQL> DELETE FROM emp WHERE job = 'CLERK'; 4 rows deleted. SQL> COMMIT;

Commit complete. SQL> SELECT COUNT(*) FROM emp; COUNT(*) ---------10 TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE. Example:SQL> TRUNCATE TABLE emp; Table truncated. SQL> SELECT COUNT(*) FROM emp; COUNT(*) ---------0

24) CREATE TABLE .. AS SELECT command To copy only the structure, the WHERE clause of the SELECT command should contai n a FALSE statement as in the following example:CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2; If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.

Vous aimerez peut-être aussi